Search Results

Search found 171 results on 7 pages for 'marty heath'.

Page 5/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • Looping through macro Varargs values

    - by Ed Marty
    If I define some macro: #define foo(args...) ({/*do something*/}) Is there some way to actually loop through args rather than pass it along to another function? Something like #define foo(args...) \ { \ for (int i = 0; i < sizeof(args); ++i) { \ /*do something with args[i]*/ \ } \ }

    Read the article

  • counting twice in a query, once using restrictions

    - by Andrew Heath
    Given the following tables: Table1 [class] [child] math boy1 math boy2 math boy3 art boy1 Table2 [child] [glasses] boy1 yes boy2 yes boy3 no If I want to query for number of children per class, I'd do this: SELECT class, COUNT(child) FROM Table1 GROUP BY class and if I wanted to query for number of children per class wearing glasses, I'd do this: SELECT Table1.class, COUNT(table1.child) FROM Table1 LEFT JOIN Table2 ON Table1.child=Table2.child WHERE Table2.glasses='yes' GROUP BY Table1.class but what I really want to do is: SELECT class, COUNT(child), COUNT(child wearing glasses) and frankly I have no idea how to do that in only one query. help?

    Read the article

  • Why doesn't java.util.Set have get(int index)?

    - by Marty Pitt
    I'm sure there's a good reason, but could someone please explain why the java.util.Set interface lacks get(int Index), or any similar get() method? It seems that sets are great for putting things into, but I can't find an elegant way of retrieving a single item from it. If I know I want the first item, I can use set.iterator().next(), but otherwise it seems I have to cast to an Array to retrieve an item at a specific index? What are the appropriate ways of retrieving data from a set? (other than using an iterator) I'm sure the fact that it's excluded from the API means there's a good reason for not doing this -- could someone please enlighten me? EDIT: Some extremely great answers here, and a few saying "more context". The specific scneario was a dbUnit test, where I could reasonalby assert that the returned set from a query had only 1 item, and I was trying to access that item. However, the question is more valid without the scenario, as it remains more focussed : What's the difference between set & list. Thanks to all for the fantastic answers below.

    Read the article

  • MVC View Model Intellesense / Compile error

    - by Marty Trenouth
    I have one Library with my ORM and am working with a MVC Application. I have a problem where the pages won't compile because the Views can't see the Model's properties (which are inherited from lower level base classes). They system throws a compile error saying that 'object' does not contain a definition for 'ID' and no extension method 'ID' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) implying that the View is not seeing the model. In the Controller I have full access to the Model and have check the Inherits from portion of the view to validate the correct type is being passed. Controller: return View(new TeraViral_Blog()); View: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<com.models.TeraViral_Blog>" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Index2 </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>Index2</h2> <fieldset> <legend>Fields</legend> <p> ID: <%= Html.Encode(Model.ID) %> </p> </fieldset> </asp:Content>

    Read the article

  • Is there an easy way to stream a m3u in iPhone?

    - by marty
    I can have a UIWebView with the .m3u file opened, which will go to the webview with a play button displayed, and that automatically goes to the quicktime player and starts playing the stream. But when I press the done button, it goes back to the UIWebView with a little play button in the middle, and from there you can go back to the previous screen (it was selected from a tableview). So I just want it to automatically load the quicktime player in the view. How can I do that?

    Read the article

  • How do I recycle code in Visual Studio with XNA?

    - by Marty Wallace
    I'm relatively new to both C# and Visual Studio, using XNA Game Studio. All I want to do is take some folders from a current project which contain .cs files and utilise those files in a new project, but it's proving to be a little trickier than I am used to with Flash/ActionScript. At the moment it seems like I need to use this process over and over until all the files I want are part of the current project:

    Read the article

  • How do I sort feeds returned from Google Reader?

    - by Ed Marty
    When I query Google Reader for the list of subscriptions for a user, it seems to be returned in a fixed order, no matter what the order is as shown at google.com/reader. (see http://www.google.com/reader/api/0/subscription/list for the list I'm talking about) Each subscription returns a 'sortid', which Google Reader uses when the user rearranges subscriptions, by sending back a concatenation of all sortids in the new order after rearranging is finished. However, that sortid never changes. So my question is this: How do I actually get the order the subscriptions are supposed to be in? I've been using http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI as a reference, but it is lacking in this department, and I haven't found anything anywhere else either.

    Read the article

  • DBTransactions between stateless calls using GUIDs

    - by Marty Trenouth
    I'm looking to add transactional support to my DB engine and providing to Abstract Transaction Handling down to passing in Guids with the DB Action Command. The DB engine would run similar to: private static Database DB; public static Dictionary<Guid,DBTransaction> Transactions = new ...() public static void DoDBAction(string cmdstring,List<Parameter> parameters,Guid TransactionGuid) { DBCommand cmd = BuildCommand(cmdstring,parameters); if(Transactions.ContainsKey(TransactionGuid)) cmd.Transaction = Transactions[TransactionGuid]; DB.ExecuteScalar(cmd); } public static BuildCommand(string cmd, List<Parameter> parameters) { // Create DB command from EntLib Database and assign parameters } public static Guid BeginTransaction() { // creates new Transaction adding it to "Transactions" and opens a new connection } public static Guid Commit(Guid g) { // Commits Transaction and removes it from "Transactions" and closes connection } public static Guid Rollback(Guid g) { // Rolls back Transaction and removes it from "Transactions" and closes connection } The Calling system would run similar to: Guid g try { g = DBEngine.BeginTransaction() DBEngine.DoDBAction(cmdstring1, parameters,g) // do some other stuff DBEngine.DoDBAction(cmdstring2, parameters2,g) // sit here and wait for a response from other item DBEngine.DoDBAction(cmdstring3, parameters3,g) DBEngine.Commit(g) } catch(Exception){ DBEngine.Rollback(g);} Does this interfere with .NET connection pooling (other than a connection be accidently left open)? Will EntLib keep the connection open until the commit or rollback?

    Read the article

  • mysql_query -- question about results "location"

    - by Andrew Heath
    Forgive me if this is a particularly stupid question! mysql_query($query) returns a boolean, but you can also assign it to a variable $results = mysql_query($query) and then use the other mysql_ functions to extract data. Out of curiosity, how does mysq_query($query) act as both a boolean and a data container at the same time? What's happening "under the hood" during these steps? (yes, I am a n00b..., please be kind!)

    Read the article

  • query structure - ignoring entries for the same event from multiple users?

    - by Andrew Heath
    One table in my MySQL database tracks game plays. It has the following structure: SCENARIO_VICTORIES [ID] [scenario_id] [game] [timestamp] [user_id] [winning_side] [play_date] ID is the autoincremented primary key. timestamp records the moment of submission for the record. winning_side has one of three possible values: 1, 2, or 0 (meaning a draw) One of the queries done on this table calculates the victory percentage for each scenario, when that scenario's page is viewed. The output is expressed as: Side 1 win % Side 2 win % Draw % and queried with: SELECT winning_side, COUNT(scenario_id) FROM scenario_victories WHERE scenario_id='$scenID' GROUP BY winning_side ORDER BY winning_side ASC and then processed into the percentages and such. Sorry for the long setup. My problem is this: several of my users play each other, and record their mutual results. So these battles are being doubly represented in the victory percentages and result counts. Though this happens infrequently, the userbase isn't large and the double entries do have a noticeable effect on the data. Given the table and query above - does anyone have any suggestions for how I can "collapse" records that have the same play_date & game & scenario_id & winning_side so that they're only counted once?

    Read the article

  • mysql_fetch_array() problem

    - by Marty
    So I have 3 DB tables that are all identical in every way (data is different) except the name of the table. I did this so I could use one piece of code with a switch like so: function disp_bestof($atts) { extract(shortcode_atts(array( 'topic' => '' ), $atts)); $connect = mysql_connect("localhost","foo","bar"); if (!$connect) { die('Could not connect: ' . mysql_error()); } switch ($topic) { case "attorneys": $bestof_query = "SELECT * FROM attorneys p JOIN (awards a, categories c, awardLevels l) ON (a.id = p.id AND c.id = a.category AND l.id = a.level) ORDER BY a.category, a.level ASC"; $category_query = "SELECT * FROM categories"; $db = mysql_select_db('roanoke_BestOf_TopAttorneys'); $query = mysql_query($bestof_query); $categoryQuery = mysql_query($category_query); break; case "physicians": $bestof_query = "SELECT * FROM physicians p JOIN (awards a, categories c, awardLevels l) ON (a.id = p.id AND c.id = a.category AND l.id = a.level) ORDER BY a.category, a.level ASC"; $category_query = "SELECT * FROM categories"; $db = mysql_select_db('roanoke_BestOf_TopDocs'); $query = mysql_query($bestof_query); $categoryQuery = mysql_query($category_query); break; case "dining": $bestof_query = "SELECT * FROM restaurants p JOIN (awards a, categories c, awardLevels l) ON (a.id = p.id AND c.id = a.category AND l.id = a.level) ORDER BY a.category, a.level ASC"; $category_query = "SELECT * FROM categories"; $db = mysql_select_db('roanoke_BestOf_DiningAwards'); $query = mysql_query($bestof_query); $categoryQuery = mysql_query($category_query); break; default: $bestof_query = "switch on $best did not match required case(s)"; break; } $category = ''; while( $result = mysql_fetch_array($query) ) { if( $result['category'] != $category ) { $category = $result['category']; //echo "<div class\"category\">"; $bestof_content .= "<h2>".$category."</h2>\n"; //echo "<ul>"; Now, this whole thing works PERFECT for the first two cases, but the third one "dining" breaks with this error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource ... on line 78 Line 78 is the while() at the bottom. I have checked and double checked and can't figure what the problem is. Here's the DB structure for 'restaurants': CREATE TABLE `restaurants` ( `id` int(10) NOT NULL auto_increment, `restaurant` varchar(255) default NULL, `address1` varchar(255) default NULL, `address2` varchar(255) default NULL, `city` varchar(255) default NULL, `state` varchar(255) default NULL, `zip` double default NULL, `phone` double default NULL, `URI` varchar(255) default NULL, `neighborhood` varchar(255) default NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=249 DEFAULT CHARSET=utf8 Does anyone see what I'm doing wrong here? I'm passing "dining" to the function and as I said before, the first two cases in the switch work fine. I'm sure it's something stupid...

    Read the article

  • C# implementation of PushbackInputStream

    - by Mark Heath
    I need a C# implementation of Java's PushbackInputStream. I have made my own very basic one, but I wondered if there was a well tested and decently performing version already available somewhere. As it happens I always push back the same bytes I read so really it just needs to be able to reposition backwards, buffering up to a number of bytes I specify. (like Java's BufferedInputStream with the mark and reset methods). Update: I should add that I can't simply reposition the stream as CanSeek may be false. (e.g. when the input steam is a NetworkStream)

    Read the article

  • Why do people develop emotional attachments for programming languages?

    - by Andrew Heath
    Aside from people who actually developed the languages, I really don't get how someone can develop passion/attachment/perhaps even obsession for a programming language... yet not a day goes by that I don't see a programmer exhibiting this behavior on the internet. I understand how people can feel this way regarding spoken languages - but there's a whole boatload of culture, history, etc that come attached with them. By comparison, the "Python Culture" (as an example) is so small as to be wholly insignificant. Does everyone have a language they love? Am I the odd one out? The dirty polygamist? Are these people rational or silly?

    Read the article

  • Div width: auto and IE

    - by Andrew Heath
    I'm using the jQuery qTip to show individual users and their votes when an average rating is mousedover. qTip calls a PHP file which grabs all the users and votes for the item from the MySQL database and builds a 3 column table, which appears as the tooltip. In Firefox, the tooltip displays properly. In IE7 (haven't tested on IE8 yet), the tooltip is the proper height, but the width is only 2 or 3 characters - not the entire table. If I set the width of the div to a fixed number, say width: 300px; I can coax IE into displaying it properly. However, the length of my users' names varies considerably, and I'd rather not nail down the div to its maximum possible width and then have a crapload of whitespace when you look at an item voted on only by "Joe". Using width: auto; has no effect in IE7. Are there alternatives? Sorry if I've overlooked a similar question. I searched for a bit before posting but didn't find anything suitable. EDIT TO ADD CODE: <div style="-moz-border-radius: 0pt 0pt 0pt 0pt; position: absolute; width: 358px; display: none; top: 384.617px; left: 463.5px; z-index: 6000;" class="qtip qtip-defaults" qtip="0"> <div style="position: relative; overflow: hidden; text-align: left;" class="qtip-wrapper"> <div style="overflow: hidden; background: none repeat scroll 0% 0% white; border: 1px solid rgb(211, 211, 211);" class="qtip-contentWrapper"> <div class="qtip-content qtip-content" style="background: none repeat scroll 0% 0% white; color: rgb(17, 17, 17); overflow: hidden; text-align: left; padding: 5px 9px;"> <div id="WhoResults"> <table> <tbody> <tr> <td>guy1</td> <td>guy2</td> <td>guy3</td> </tr> <tr> <td>guy4</td> <td>guy5</td> <td>guy6</td> </tr> </tbody> </table> </div> </div> </div> </div> </div> I have applied no CSS styling. That's all been handled by qTip. I tried to format it as best I could. Thanks for any help you can provide.

    Read the article

  • php error reporting - having trouble matching local & web server settings

    - by Andrew Heath
    I'm trying to add a custom error handler to my site, but in doing so have discovered that my webhost's PHP error reporting settings and those of my localhost (default XAMPP) vary considerably. While I thought I was programming to E_STRICT like a good little boy, adding the error handler to my webhost revealed craploads of Runtime Notices. Example: Runtime notice strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Chicago' for 'CST/-6.0/no DST' instead In /home/... Clearly this isn't a red-alert, showstopping error. But what bothers me is that it doesn't show up on my localhost. I'd certainly like to improve my code by addressing these sorts of issues if I could see them! I've looked through both php.ini files, and my webhost's setting is error_reporting = E_ALL & ~E_NOTICE whereas mine was error_reporting = E_STRICT, which I had thought was better. However, changing mine to match and rebooting the server doesn't seem to have accomplished anything. Could someone please point me in the right direction?

    Read the article

  • getting number of hours until the next event

    - by Andrew Heath
    I've got a table with this data: [ID] [event_name] [last_event] 1 stats 2011-01-01 01:47:32 last_event is a timestamp. The event occurs every 48 hours (it's a cron job). I'd like to show my users the number of hours until the event executes again. So far I've got: SELECT (lastFinish + INTERVAL 48 HOUR) FROM `cron_status` which gives me the exact time and date of the next occurence: 2011-01-03 01:47:32. So I figured if I subtracted the current datetime... SELECT ((lastFinish + INTERVAL 48 HOUR) - SYSDATE()) FROM `cron_status` which (I think?) gives me the difference in unix time: 1980015. But if I divide that by 3600 to convert the seconds to hours... SELECT (((lastFinish + INTERVAL 48 HOUR) - SYSDATE())/3600) FROM `cron_status` I get numbers an order of magnitude too high: 549.99. Where am I going wrong? The target is returning the number of hours until the next execution. Thank you!

    Read the article

  • Base64 Encoded Data - DB or Filesystem

    - by Marty
    I have a new program that will be generating a lot of Base64 encoded audio and image data. This data will be served via HTTP in the form of XML and the Base64 data will be inline. These files will most likely break 20MB and higher. Would it be more efficient to serve these files directly from the filesystem or would it be feasible to store the data in a MySQL database? Caching will be set up but overall unnecessary because it is likely that this data will be purged shortly after it is created and served. i know that storing binary data in the DB is frowned upon in most circumstances but since this will all be character data I want to see what the consensus is. As of now, I am leaning toward storing them in the filesystem for efficiency reasons but if it is feasible to store them in a database it would be much easier to manage the data.

    Read the article

  • How can I stop the iPhone from displaying a transform change until after the screen is redrawn

    - by Ed Marty
    I have found the UIScrollView's zooming mechanism to be clunk and essentially unusable. So instead, I'm rolling my own. I have a UIView that resizes itself with the pinch-zoom, and that's working fine. When the zoom is complete, the view needs to reset its transform and redraw the images. The zoom works essentially in the same way the UIScrollView does. It sets the transform property of the UIView until complete. Then, when the zoom finishes, I want to reset the transform to CGAffineTransformIdentity, resize the frame to be the size it was before, and tell the view to redraw itself at the new size. It all works pretty well, except when I change the transform to identity then redraw the image, there is a slight flicker before the image completely redraws. This is due to the fact that I'm using a subclass of CATiledLayer, since the view can be of arbitrary size. I've overridden the fadeDuration to be zero, but there is still a flicker while the transform is reset before the redraw is finished. Is there any simple way to overcome this without creating another view to draw with then replacing it?

    Read the article

  • PHP Function parameters - problem with var not being set

    - by Marty
    So I am obviously not a very good programmer. I have written this small function: function dispAdjuggler($atts) { extract(shortcode_atts(array( 'slot' => '' ), $atts)); $adspot = ''; $adtype = ''; // Get blog # we're on global $blog_id; switch ($blog_id) { case 1: // root blog HOME page if (is_home()) { switch ($slot) { case 'top_leaderboard': $adspot = '855525'; $adtype = '608934'; break; case 'right_halfpage': $adspot = '855216'; $adtype = '855220'; break; case 'right_med-rectangle': $adspot = '858222'; $adtype = '613526'; break; default: throw new Exception("Ad slot is not defined"); break; } When I reference the function on a page like so: <?php dispAdjuggler("top_leaderboard"); ?> The switch is throwing the default exception. What am I doing wrong here? Thanks!!

    Read the article

  • MySQL join headaches, please help!

    - by Andrew Heath
    Ok, I've hit the wall here and need some help. Sample tables are as follows: SCENARIO_NATIONS [scenID] [side] [nation] scen001 1 Germany scen001 2 Britain scen001 2 Canada SCENARIO_NEEDUNITS [scenID] [unitID] scen001 0001 scen001 0003 scen001 0107 scen001 0258 scen001 0759 UNIT_BASIC_DATA [unitID] [nation] [name] 0001 Germany Mortars 0003 Germany Infantry 0107 Britain Lt 0258 Britain Infantry 0759 Canada Kilted Yaksmen Goal: given a scenID, pull a list of units from the database sorted by side, nation, name. I can do everything except for the side inclusion with: SELECT scenario_needunits.scenID, unit_basic_data.nation, unit_basic_data.name FROM scenario_needunits LEFT OUTER JOIN unit_basic_data ON scenario_needunits.unitID=unit_basic_data.unitID WHERE scenario_needunits.scenID='scen001' ORDER BY unit_basic_data.nation ASC, unit_basic_data.name ASC I've tried just dropping the SCENARIO_NATIONS table in as a LEFT OUTER JOIN on scenID but what ends up happening is that ALL units come back with a side of 1 because that's always the first side listed for the scenID in the SCENARIO_NATIONS table. Conceptually, what I think needs to happen is SCENARIO_NATIONS must be joined to both the scenID (to restrict it to just that scenario) and to each unit's nation but I don't have any idea how to do that and my Google-fu is inadequate. :-/

    Read the article

  • unfounded Secure Unsecure Messages

    - by Marty Trenouth
    I'm having significant difficulty locating the root cause for a secure/insecure message comming from IE. I've looked through the entire output and there are NO references to http: I've searched for unsource Iframes, which cause this message, and there are none and other than jquery 1.4 there isn't even the text "iframe" in the source. I'm almost at an end trying the cause for this. Does anyone have any ideas

    Read the article

  • Java algorithm for normalizing audio

    - by Marty Pitt
    I'm trying to normalize an audio file of speech. Specifically, where an audio file contains peaks in volume, I'm trying to level it out, so the quiet sections are louder, and the peaks are quieter. I know very little about audio manipulation, beyond what I've learnt from working on this task. Also, my math is embarrassingly weak. I've done some research, and the Xuggle site provides a sample which shows reducing the volume using the following code: (full version here) @Override public void onAudioSamples(IAudioSamplesEvent event) { // get the raw audio byes and adjust it's value ShortBuffer buffer = event.getAudioSamples().getByteBuffer().asShortBuffer(); for (int i = 0; i < buffer.limit(); ++i) buffer.put(i, (short)(buffer.get(i) * mVolume)); super.onAudioSamples(event); } Here, they modify the bytes in getAudioSamples() by a constant of mVolume. Building on this approach, I've attempted a normalisation modifies the bytes in getAudioSamples() to a normalised value, considering the max/min in the file. (See below for details). I have a simple filter to leave "silence" alone (ie., anything below a value). I'm finding that the output file is very noisy (ie., the quality is seriously degraded). I assume that the error is either in my normalisation algorithim, or the way I manipulate the bytes. However, I'm unsure of where to go next. Here's an abridged version of what I'm currently doing. Step 1: Find peaks in file: Reads the full audio file, and finds this highest and lowest values of buffer.get() for all AudioSamples @Override public void onAudioSamples(IAudioSamplesEvent event) { IAudioSamples audioSamples = event.getAudioSamples(); ShortBuffer buffer = audioSamples.getByteBuffer().asShortBuffer(); short min = Short.MAX_VALUE; short max = Short.MIN_VALUE; for (int i = 0; i < buffer.limit(); ++i) { short value = buffer.get(i); min = (short) Math.min(min, value); max = (short) Math.max(max, value); } // assign of min/max ommitted for brevity. super.onAudioSamples(event); } Step 2: Normalize all values: In a loop similar to step1, replace the buffer with normalized values, calling: buffer.put(i, normalize(buffer.get(i)); public short normalize(short value) { if (isBackgroundNoise(value)) return value; short rawMin = // min from step1 short rawMax = // max from step1 short targetRangeMin = 1000; short targetRangeMax = 8000; int abs = Math.abs(value); double a = (abs - rawMin) * (targetRangeMax - targetRangeMin); double b = (rawMax - rawMin); double result = targetRangeMin + ( a/b ); // Copy the sign of value to result. result = Math.copySign(result,value); return (short) result; } Questions: Is this a valid approach for attempting to normalize an audio file? Is my math in normalize() valid? Why would this cause the file to become noisy, where a similar approach in the demo code doesn't?

    Read the article

  • getting userbase vote average and individual user's vote in the same query?

    - by Andrew Heath
    Here goes: T1 [id] [desc] 1 lovely 2 ugly 3 slender T2 [id] [userid] [vote] 1 1 3 1 2 5 1 3 2 2 1 1 2 2 4 2 3 4 In one query (if possible) I'd like to return: T1.id, T1.desc, AVG(T2.vote), T2.vote (for user viewing the page) I can get the first 3 items with: SELECT T1.id, T1.desc, AVG(T2.vote) FROM T1 LEFT JOIN T2 ON T1.id=T2.id GROUP BY T1.id and I can get the first, second, and fourth items with: SELECT T1.id, T1.desc, T2.vote FROM T1 LEFT JOIN T2 ON T1.id=T2.id WHERE T2.userid='1' GROUP BY T1.id but I'm at a loss as to how to get all four items in one query. I tried inserting a select as the fourth term: SELECT T1.id, T1.desc, AVG(T2.vote), (SELECT T2.vote FROM T2 WHERE T2.userid='1') AS userVote etc etc but I get an error that the select returns more than one row... Help? My reason for wanting to do this in one query instead of two is that I want to be able to sort the data within MySQL rather than one it's been split into a number of arrays.

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >