Search Results

Search found 1896 results on 76 pages for 'paul dinh'.

Page 48/76 | < Previous Page | 44 45 46 47 48 49 50 51 52 53 54 55  | Next Page >

  • What is the Proper approach for Constructing a PhysicalAddress object from Byte Array

    - by Paul Farry
    I'm trying to understand what the correct approach for a constructor that accepts a Byte Array with regard to how it stores it's data (specifically with PhysicalAddress) I have an array of 6 bytes (theAddress) that is constructed once. I have a source array of 18bytes (theAddresses) that is loaded from a TCP Connection. I then copy the 6bytes from theAddress+offset into theAddress and construct the PhysicalAddress from it. Problem is that the PhysicalAddress just stores the Reference to the array that was passed in. Therefore if you subsequently check the addresses they only ever point to the last address that was copied in. When I took a look inside the PhysicalAddress with reflector it's easy to see what's going on. public PhysicalAddress(byte[] address) { this.changed = true; this.address = address; } Now I know this can be solved by creating theAddress array on each pass, but I wanted to find out what really is the best practice for this. Should the constructor of an object that accepts a byte array create it's own private Variable for holding the data and copy it from the original Should it just hold the reference to what was passed in. Should I just created theAddress on each pass in the loop

    Read the article

  • IOS Paypal Phonegap Plugin errors

    - by Paul
    I'm trying to implement the Paypal Plugin for Phonegap (Iphone) - (https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/PayPalPlugin). I've followed all the instructions but I get thefollowing error on build from the SAIOSPaypalPlugin.h file - Lexical or Preprocessor issue - PGPlugin.h not found I'm using latest Cordova version freshly downloaded from Phonegap site just weeks ago, so I'm not sure whats missing?

    Read the article

  • Installing a condition handler in Common Lisp

    - by Paul Nathan
    The HTTP library Drakma on CLISP generates an error USOCKET:UNSUPPORTED due to a bug in Drakma+CLISP. However, it turns out that the CONTINUE restart seems to work fine. Therefore, I spent some time with CLtL and other references trying to determine how to write a restart handler. (defun http-request (url param) (handler-bind ((USOCKET:UNSUPPORTED #'(lambda (x) (invoke-restart 'continue))))) (drakma:http-request url :method :post :parameters param)) According to my best understanding, the above code should trap the error USOCKET:UNSUPPORTED. It doesn't; it seems to ignore the error binder. How do I fix this?

    Read the article

  • Is it possible to parse a URL into it's composite components?

    - by Paul Alexander
    I'd like to parse an incoming URL into it's component parts for some pre-processing before passing it into the standard MVC routing logic. For example given your standard route {controller}/{action}/{id} and the URL /user/show/10 Is there a way to have the Routing system return a dictionary containing controller, action and id keys with their corresponding values?

    Read the article

  • Poor man's "lexer" for C#

    - by Paul Hollingsworth
    I'm trying to write a very simple parser in C#. I need a lexer -- something that lets me associate regular expressions with tokens, so it reads in regexs and gives me back symbols. It seems like I ought to be able to use Regex to do the actual heavy lifting, but I can't see an easy way to do it. For one thing, Regex only seems to work on strings, not streams (why is that!?!?). Basically, I want an implementation of the following interface: interface ILexer : IDisposable { /// <summary> /// Return true if there are more tokens to read /// </summary> bool HasMoreTokens { get; } /// <summary> /// The actual contents that matched the token /// </summary> string TokenContents { get; } /// <summary> /// The particular token in "tokenDefinitions" that was matched (e.g. "STRING", "NUMBER", "OPEN PARENS", "CLOSE PARENS" /// </summary> object Token { get; } /// <summary> /// Move to the next token /// </summary> void Next(); } interface ILexerFactory { /// <summary> /// Create a Lexer for converting a stream of characters into tokens /// </summary> /// <param name="reader">TextReader that supplies the underlying stream</param> /// <param name="tokenDefinitions">A dictionary from regular expressions to their "token identifers"</param> /// <returns>The lexer</returns> ILexer CreateLexer(TextReader reader, IDictionary<string, object> tokenDefinitions); } So, pluz send the codz... No, seriously, I am about to start writing an implementation of the above interface yet I find it hard to believe that there isn't some simple way of doing this in .NET (2.0) already. So, any suggestions for a simple way to do the above? (Also, I don't want any "code generators". Performance is not important for this thing and I don't want to introduce any complexity into the build process.)

    Read the article

  • Debugging/Running executables in cmake/Visual Studio project

    - by Paul
    We are moving from hand-managed Visual Studio projects to cross platform cmake. We used to open a solutions file, select a project as "Startup Target" and push Ctrl+F5 or F5 debug or run. Now cmake has this install concept. It requires me to run the install target. But the install project doesn't have any executables set so it can not be used to start with debugging. If I set my executable project as a startup target, then install will not run, so I can not debug. I am sure there is a better way of doing this. Any ideas ?

    Read the article

  • Disable system sleep during long builds

    - by Paul Alexander
    From time to time I need to run a full build of the entire tool chain for our software on my development machine. To save on power my I've got my dev machine set to go sleep after 20 minutes of inactivity. Building the full tool chain can take up to an hour and I'll often just go to lunch. However, if I forget to disable sleep I can return to a sleeping machine with the build only partially complete. What I'm looking for is a way to automatically disable sleep while MSBuild is running. Does anyone know of a simple way of doing this?

    Read the article

  • Can I make ungetc unblock a blocking fgetc call?

    - by Paul Beckingham
    I would like to stuff an 'A' character back into stdin using ungetc on receipt of SIGUSR1. Imagine that I have a good reason for doing this. When calling foo(), the blocking read in stdin is not interrupted by the ungetc call on receipt of the signal. While I didn't expect this to work as is, I wonder if there is a way to achieve this - does anyone have suggestions? void handler (int sig) { ungetc ('A', stdin); } void foo () { signal (SIGUSR1, handler); while ((key = fgetc (stdin)) != EOF) { ... } }

    Read the article

  • UIScrollView Does not Scroll

    - by paul simmons
    I have added a long info screen to my iPhone app. The info is a long UIImageView, and it is contained inside a UIScrollView. They are both defined in .xib file. At run-time, initially I set scrollview's position outside window, and when user clicks a button, set its position inside window. This part is OK. But scrollview displays the image but does not scroll. Isn't it enough to place in MainViewContoller.xib, set the contained content, and (at code) set its contentSize equal to the content's size? BTW: I try it at simulator currently.

    Read the article

  • Moq.Mock<T> - how to setup a method that takes an expression

    - by Paul
    I am Mocking my repository interface and am not sure how to setup a method that takes an expression and returns an object? I am using Moq and NUnit Interface: public interface IReadOnlyRepository : IDisposable { IQueryable<T> All<T>() where T : class; T Single<T>(Expression<Func<T, bool>> expression) where T : class; } Test with IQueryable already setup, but don't know how to setup the T Single: private Moq.Mock<IReadOnlyRepository> _mockRepos; private AdminController _controller; [SetUp] public void SetUp() { var allPages = new List<Page>(); for (var i = 0; i < 10; i++) { allPages.Add(new Page { Id = i, Title = "Page Title " + i, Slug = "Page-Title-" + i, Content = "Page " + i + " on page content." }); } _mockRepos = new Moq.Mock<IReadOnlyRepository>(); _mockRepos.Setup(x => x.All<Page>()).Returns(allPages.AsQueryable()); //Not sure what to do here??? _mockRepos.Setup(x => x.Single<Page>() //---- _controller = new AdminController(_mockRepos.Object); }

    Read the article

  • Centering Text Horizontally and Vertically in LaTeX

    - by Paul
    I would like to produce the following: a b xxxxx xxxxx 1 xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx 2 xxxxx xxxxx xxxxx xxxxx Where the blocks of 'x's are images, and 'a', 'b', '1' and '2' are text. Here are my two attempts so far: \begin{figure} \begin{center} \begin{tabular}{ccc} & a & b \\ 1 & \subfloat[]{\includegraphics[width=0.47\textwidth]{im.png}} & \subfloat[]{\includegraphics[width=0.47\textwidth]{im.png}} \\ 2 & \subfloat[]{\includegraphics[width=0.47\textwidth]{im.png}} & \subfloat[]{\includegraphics[width=0.47\textwidth]{im.png}} \\ \end{tabular} \end{center} \end{figure} Which produces: a b xxxxx xxxxx xxxxx xxxxx 1 xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx 2 xxxxx xxxxx And \begin{figure} \begin{center} \begin{tabular}{m{1cm}m{6cm}m{6cm}} & a & b \\ 1 & \subfloat[]{\includegraphics[width=0.47\textwidth]{im.png}} & \subfloat[]{\includegraphics[width=0.47\textwidth]{im.png}} \\ 2 & \subfloat[]{\includegraphics[width=0.47\textwidth]{im.png}} & \subfloat[]{\includegraphics[width=0.47\textwidth]{im.png}} \\ \end{tabular} \end{center} \end{figure} Which produces: a b xxxxx xxxxx 1 xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx 2 xxxxx xxxxx xxxxx xxxxx

    Read the article

  • Why are my ActiveRecord class instance variables disappearing after the first request in development

    - by Paul C
    I have a class instance variable on one of my AR classes. I set its value at boot with an initializer and, after that, never touch it again except to read from it. In development mode, this value disappears after the first request to the web server. However, when running tests, using the console or running the production server this does not happen. # The AR class class Group < ActiveRecord::Base class << self attr_accessor :path end end # The initializer Group.path = File.join(RAILS_ROOT, "public", "etc") # First request in a view %p= Group.path #=> "/home/rails/app/public/etc" # Second request in a view %p= Group.path #=> nil Is there something about development mode that nukes instance variables from classes with each request? If so, is there a way to disable this for specific variables or classes?

    Read the article

  • How to call Javascript fun() in JSF EL conditionally?

    - by Paul
    I have to call Javascript funtion based on the bean value. i use the following code onmouseover="#{occasionBean.user.userPreference.defaultPreview==true?'':'Tip()'})" I need to send some parameters in Tip() like this Tip('') Error i am getting is javax.servlet.jsp.JspException: javax.faces.el.EvaluationException: com.sun.faces.el.impl.parser.ParseException: Encountered "test" at line 1, column 60. Was expecting one of: "}" ... "." ... "" ... "gt" ... "<" ... "lt" ... "==" ... "eq" ... "<=" ... "le" ... "=" ... "ge" ... "!=" ... "ne" ... "[" ... "+" ... "-" ... "*" ... "/" ... "div" ... "%" ... "mod" ... "and" ... "&&" ... "or" ... "||" ... "?" ... '

    Read the article

  • Gotchas INSERTing into SQLite on Android?

    - by paul.meier
    Hi friends, I'm trying to set up a simple SQLite database in Android, handling the schema via a subclass of SQLiteOpenHelper. However, when I query my tables, the columns I think I've inserted are never present. Namely, in SQLiteOpenHelper's onCreate(SQLiteDatabase db) method, I use db.execSQL() to run CREATE TABLE commands, then have tried both db.execSQL and db.insert() to run INSERT commands on the tables I've just created. This appears to run fine, but when I try to query them I always get 0 rows returned (for debugging, the queries I'm running are simple SELECT * FROM table and checking the Cursor's getCount()). Anybody run into anything like this before? These commands seem to run on command-line sqlite3. Are they're gotchas that I'm missing (e.g. INSERTS must/must not be semicolon terminated, or some issue involving multiple tables)? I've attached some of the code below. Thanks for your time, and let me know if I can clarify further. @Override public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE "+ LEVEL_TABLE +" (" + " "+ _ID +" INTEGER PRIMARY KEY AUTOINCREMENT," + " level TEXT NOT NULL,"+ " rows INTEGER NOT NULL,"+ " cols INTEGER NOT NULL);"); db.execSQL("CREATE TABLE "+ DYNAMICS_TABLE +" (" + " level_id INTEGER NOT NULL," + " row INTEGER NOT NULL,"+ " col INTEGER NOT NULL,"+ " type INTEGER NOT NULL);"); db.execSQL("CREATE TABLE "+ SCORE_TABLE +" (" + " level_id INTEGER NOT NULL," + " score INTEGER NOT NULL,"+ " date_achieved DATE NOT NULL,"+ " name TEXT NOT NULL);"); this.enterFirstLevel(db); } And a sample of the insert code I'm currently using, which gets called in enterFirstLevel() (some values hard-coded just to get it running...): private void insertDynamic(SQLiteDatabase db, int row, int col, int type) { ContentValues values = new ContentValues(); values.put("level_id", "1"); values.put("row", Integer.toString(row)); values.put("col", Integer.toString(col)); values.put("type", Integer.toString(type)); db.insertOrThrow(DYNAMICS_TABLE, "col", values); } Finally, query code looks like this: private Cursor fetchLevelDynamics(int id) { SQLiteDatabase db = this.leveldata.getReadableDatabase(); try { String fetchQuery = "SELECT * FROM " + DYNAMICS_TABLE; String[] queryArgs = new String[0]; Cursor cursor = db.rawQuery(fetchQuery, queryArgs); Activity activity = (Activity) this.context; activity.startManagingCursor(cursor); return cursor; } finally { db.close(); } }

    Read the article

  • XSD and plain text

    - by Paul Knopf
    I have a rest/xml service that gives me the following... <verse-unit unit-id="38009001"> <marker class="begin-verse" mid="v38009001"/> <begin-chapter num="9"/><heading>Judgment on Israel&apos;s Enemies</heading> <begin-block-indent/> <begin-paragraph class="line-group"/> <begin-line/><verse-num begin-chapter="9">1</verse-num>The burden of the word of the <span class="divine-name">Lord</span> is against the land of Hadrach<end-line class="br"/> <begin-line class="indent"/>and Damascus is its resting place.<end-line class="br"/> <begin-line/>For the <span class="divine-name">Lord</span> has an eye on mankind<end-line class="br"/> <begin-line class="indent"/>and on all the tribes of Israel,<footnote id="f1"> A slight emendation yields <i> For to the <span class="divine-name">Lord</span> belongs the capital of Syria and all the tribes of Israel </i> </footnote><end-line class="br"/> </verse-unit> I used visual studio to generate a schema from this and used XSD.EXE to generate classes that I can use to deserialize this mess into programmable stuff. I got everything to work and it is deserialized perfectly (almost). The problem I have is with the random text mixed throughout the child nodes. The generated verse-unit objects gives me a list of objects (begin-line, begin-block-indent, etc), and also another list of string objects that represent the bits of string throughout the xml. Here is my schema <xs:element maxOccurs="unbounded" name="verse-unit"> <xs:complexType mixed="true"> <xs:sequence> <xs:choice maxOccurs="unbounded"> <xs:element name="marker"> <xs:complexType> <xs:attribute name="class" type="xs:string" use="required" /> <xs:attribute name="mid" type="xs:string" use="required" /> </xs:complexType> </xs:element> <xs:element name="begin-chapter"> <xs:complexType> <xs:attribute name="num" type="xs:unsignedByte" use="required" /> </xs:complexType> </xs:element> <xs:element name="heading"> <xs:complexType mixed="true"> <xs:sequence minOccurs="0"> <xs:element name="span"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="class" type="xs:string" use="required" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="begin-block-indent" /> <xs:element name="begin-paragraph"> <xs:complexType> <xs:attribute name="class" type="xs:string" use="required" /> </xs:complexType> </xs:element> <xs:element name="begin-line"> <xs:complexType> <xs:attribute name="class" type="xs:string" use="optional" /> </xs:complexType> </xs:element> <xs:element name="verse-num"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:unsignedByte"> <xs:attribute name="begin-chapter" type="xs:unsignedByte" use="optional" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:element name="end-line"> <xs:complexType> <xs:attribute name="class" type="xs:string" use="optional" /> </xs:complexType> </xs:element> <xs:element name="end-paragraph" /> <xs:element name="end-block-indent" /> <xs:element name="end-chapter" /> </xs:choice> </xs:sequence> <xs:attribute name="unit-id" type="xs:unsignedInt" use="required" /> </xs:complexType> </xs:element> WHAT I NEED IS THIS. I need the random text that is NOT surrounded by an xml node to be represented by an object so I know the order that everything is in. I know this is complicated, so let me try to simplify it. <field name="test_field_0"> Some text I'm sure you don't want. <subfield>Some text.</subfield> More text you don't want. </field> I need the xsd to generate a field object with items that can have either a text object, or a subfield object. I need to no where the random text is within the child nodes.

    Read the article

  • How to embed cover art in an MP3 file so that the iPhone player displays it when downloaded

    - by Paul Dixon
    I want to be able to provide a URL to a music track, and when that track is played on an iPhone, to show the cover art. I've tried embedding the cover art as an ID3 v2.3 tag, and while desktop players like VLC and Windows Media Player can see it, it seems the iPhone doesn't. Is this possible? Does anyone know of a way to achieve this - preferably a method which can be automated? Edit: this may not be possible - even if I add cover art with iTunes, the resulting file will still not have the coverart displayed when played as a download :(

    Read the article

  • How to extract a GUID from a Win32 DLL or OCX

    - by Paul Sasik
    We have a .NET app that needs to examine a folder that may contain COM libraries (DLL and OCX.) When we do encounter a COM library one thing we need to accomplish is to extract the GUID from the COM DLL or OCX. Is there a straightforward way to do this with .NET without using 3rd party libraries?

    Read the article

  • Can I constrain a route parameter to a certain type in ASP.net MVC?

    - by Paul Suart
    I have the following route: routes.MapRoute( "Search", // Route name "Search/{affiliateId}", // URL with parameters new { controller = "Syndication", action = "Search" } // Parameter defaults ); Is there a way I can ensure "affiliateId" is a valid Guid? I'm using MVCContrib elsewhere in my site and I'm fairly it provides a way to implement this kind of constraint.... I just don't know what it is!

    Read the article

  • How to adjust video recording brightness?

    - by Paul
    When I record videos in low-light conditions on my Motorola Droid results are poor... very dark images. On my old phone, an LG Dare, recording in low light works better thanks to a brightness adjustment in the video recorder which can be set manually... Android does not have a similar brightness adjustment when recording video. Does anyone have suggestions for how to adjust the brightness using Android's APIs? I have searched the official APIs, but I cannot find a way to control brightness.

    Read the article

  • Grails: Querying Associations causes groovy.lang.MissingMethodException

    - by Paul
    Hi, I've got an issue with Grails where I have a test app with: class Artist { static constraints = { name() } static hasMany = [albums:Album] String name } class Album { static constraints = { name() } static hasMany = [ tracks : Track ] static belongsTo = [artist: Artist] String name } class Track { static constraints = { name() lyrics(nullable: true) } Lyrics lyrics static belongsTo = [album: Album] String name } The following query (and a more advanced, nested association query) works in the Grails Console but fails with a groovy.lang.MissingMethodException when running the app with 'run-app': def albumCriteria = tunehub.Album.createCriteria() def albumResults = albumCriteria.list { like("name", receivedAlbum) artist { like("name", receivedArtist) } // Fails here maxResults(1) } Stacktrace: groovy.lang.MissingMethodException: No signature of method: java.lang.String.call() is applicable for argument types: (tunehub.LyricsService$_getLyrics_closure1_closure2) values: [tunehub.LyricsService$_getLyrics_closure1_closure2@604106] Possible solutions: wait(), any(), wait(long), each(groovy.lang.Closure), any(groovy.lang.Closure), trim() at tunehub.LyricsService$_getLyrics_closure1.doCall(LyricsService.groovy:61) at tunehub.LyricsService$_getLyrics_closure1.doCall(LyricsService.groovy) (...truncated...) Any pointers?

    Read the article

  • Database design question (Book Trading System)

    - by Paul
    Hello all! I´m developing a Book Trading System... The user will input your Book to trading... I already have a table tblBook with "all" existing books ... So the user will select one book from that list and fill the book´s CONDITIONS and Edition... So, what is a good Database design to tha case? tblBook = All books tblUserBook = All User Books And making tblUserBook to inheritance tblBook? Thanks

    Read the article

  • jquery code not working in chrome

    - by Paul
    This code works is FF and IE but not in Chrome. Any help would be greatly appreciated. Thank You! here is the html Item One Item Two Item Three Item Four Item Five Item Six Item Seven Item Eight Item Nine Item ten here is the css popularsearches { border-bottom: 1px solid #D4D4D4; border-left: 1px solid #D4D4D4; border-right: 1px solid #D4D4D4; overflow:hidden; height: 130px; width:248px; margin-bottom:20px; } popularsearches ul { padding:0 5px 0 0; margin:0; } popularsearches ul li { list-style-type:none; list-style-position:inside; border-bottom: solid 1px #D4D4D4; font-size:14px; padding:3px 0 3px 0; margin:0 0 0 10px; text-align:left; } popularsearches ul li a { text-decoration:none; } popularsearches ul li a:hover, a:link, a:visited { text-decoration:none; } popularsearches-inside { width: 500px; } popularsearches-left { float:left; width:250px; height:100px; } popularsearches-right { float:left; width:250px; height:100px; } here is the jQuery var closeinterval = 0; function scrollContent() { //Toggle left between 250 and 0 var top = jQuery("#popularsearches").scrollLeft() == 0 ? 250 : 0; jQuery("#popularsearches").animate({ scrollLeft: top }, "slow"); } // Call scrollContent function every 6 secs closeinterval = setInterval("scrollContent()", 6000); jQuery(document).ready(function() { jQuery("#popular-button-left").bind("click", function() { if (closeinterval) { window.clearInterval(closeinterval); closeinterval = null; } jQuery("#popularsearches").animate({ scrollLeft: 0 }, 1000); }); jQuery("#popular-button-right").bind("click", function() { if (closeinterval) { window.clearInterval(closeinterval) closeinterval = null; } jQuery("#popularsearches").animate({ scrollLeft: 250 }, 1000); }); });

    Read the article

< Previous Page | 44 45 46 47 48 49 50 51 52 53 54 55  | Next Page >