Search Results

Search found 3177 results on 128 pages for 'david sedai'.

Page 80/128 | < Previous Page | 76 77 78 79 80 81 82 83 84 85 86 87  | Next Page >

  • Code-Golf: Friendly Number Abbreviator

    - by David Murdoch
    Based on this question: Is there a way to round numbers into a friendly format? THE CHALLENGE - UPDATED! (removed hundreds abbreviation from spec) The shortest code by character count that will abbreviate an integer (no decimals). Code should include the full program. Relevant range is from 0 - 9,223,372,036,854,775,807 (the upper limit for signed 64 bit integer). The number of decimal places for abbreviation will be positive. You will not need to calculate the following: 920535 abbreviated -1 place (which would be something like 0.920535M). Numbers in the tens and hundreds place (0-999) should never be abbreviated (the abbreviation for the number 57 to 1+ decimal places is 5.7dk - it is unneccessary and not friendly). Remember to round half away from zero (23.5 gets rounded to 24). Banker's rounding is verboten. Here are the relevant number abbreviations: h = hundred (102) k = thousand (103) M = million (106) G = billion (109) T = trillion (1012) P = quadrillion (1015) E = quintillion (1018) SAMPLE INPUTS/OUTPUTS (inputs can be passed as separate arguments): First argument will be the integer to abbreviate. The second is the number of decimal places. 12 1 => 12 // tens and hundreds places are never rounded 1500 2 => 1.5k 1500 0 => 2k // look, ma! I round UP at .5 0 2 => 0 1234 0 => 1k 34567 2 => 34.57k 918395 1 => 918.4k 2134124 2 => 2.13M 47475782130 2 => 47.48G 9223372036854775807 3 => 9.223E // ect... . . . Original answer from related question (javascript, does not follow spec): function abbrNum(number, decPlaces) { // 2 decimal places => 100, 3 => 1000, etc decPlaces = Math.pow(10,decPlaces); // Enumerate number abbreviations var abbrev = [ "k", "m", "b", "t" ]; // Go through the array backwards, so we do the largest first for (var i=abbrev.length-1; i>=0; i--) { // Convert array index to "1000", "1000000", etc var size = Math.pow(10,(i+1)*3); // If the number is bigger or equal do the abbreviation if(size <= number) { // Here, we multiply by decPlaces, round, and then divide by decPlaces. // This gives us nice rounding to a particular decimal place. number = Math.round(number*decPlaces/size)/decPlaces; // Add the letter for the abbreviation number += abbrev[i]; // We are done... stop break; } } return number; }

    Read the article

  • Windows Azure SDK - ASPProviders example

    - by David
    Hi, since the new SDK 1.1 is missing the tutorial for "ASPProviders", i am currently asking myself how i would implement a "azure session state provider" ( this is the path in the "old" SDK: C:\Program Files\Windows Azure SDK\v1.0\Samples\AspProviders ) Related threads: http://stackoverflow.com/questions/1023108/how-does-microsoft-azure-handle-session-state http://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/2d1340ed-0ad0-456a-b069-aa6b85672102/ Has anyone an idea or even the old example project and could post some snippets of the config here?

    Read the article

  • Concatenate CLOB-rows with PL/SQL

    - by david K
    Hi, I've got a table which has an id and a clob content like: Create Table v_example_l ( nip number, xmlcontent clob ); We insert our data: Insert into V_EXAMPLE_L (NIP,XMLCONTENT) Values (17852,'<section><block><name>delta</name><content>548484646846484</content></block></section>'); Insert into V_EXAMPLE_L (NIP,XMLCONTENT) Values (17852,'<section><block><name>omega</name><content>545648468484</content></block></section>'); Insert into V_EXAMPLE_L (NIP,XMLCONTENT) Values (17852,'<section><block><name>gamma</name><content>54564846qsdqsdqsdqsd8484</content></block></section>'); I'm trying to do a function that concatenates the rows of the clob that gone be the result of a select, i mean without having to give multiple parameter about the name of table or such, i should only give here the column that contain the clobs, and it should handle the rest. CREATE OR REPLACE function assemble_clob(q varchar2) return clob is v_clob clob; tmp_lob clob; hold VARCHAR2(4000); --cursor c2 is select xmlcontent from V_EXAMPLE_L where id=17852 cur sys_refcursor; begin OPEN cur FOR q; LOOP FETCH cur INTO tmp_lob; EXIT WHEN cur%NOTFOUND; --v_clob := v_clob || XMLTYPE.getClobVal(tmp_lob.xmlcontent); v_clob := v_clob || tmp_lob; END LOOP; return (v_clob); --return (dbms_xmlquery.getXml( dbms_xmlquery.set_context("Select 1 from dual")) ) end assemble_clob; The function is broken... (if anybody could give me a help, thanks a lot, and i'm noob in sql so ....). Thanks!

    Read the article

  • trying to use ActiveRecord with Sinatra, Migration fails question

    - by David Lazar
    Hi, running Sinatra 1.0, I wanted to add a database table to my program. In my Rakefile I have a task task :environment do ActiveRecord::Base.establish_connection(YAML::load(File.open('config/database.yml'))["development"]) end I have a migration task in my namespace that calls the migration code: namespace :related_products do desc "run any migrations we may have in db/migrate" task :migrate => :environment do ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil ) end My console pukes out an error when the call to ActiveRecord::MIgrator.migrate() is made. rake aborted! undefined method `info' for nil:NilClass The migration code itself is pretty simple... and presents me with no clues as to what this missing info class is. class CreateStores < ActiveRecord::Migration def self.up create_table :stores do |t| t.string :name t.string :access_url t.timestamps end end def self.down drop_table :stores end end I am a little mystified here and am looking for some clues as to what might be wrong. Thanks!

    Read the article

  • Beginner having a problem with classes

    - by David
    I'm working through O'Reilly's "Learning Python" and having a problem with classes. I think I understand the concept, but in practice have stumbled upon this problem. Fron page 88-89: >>> class Worker: def __innit__(self, name, pay): self.name=name self.pay=pay def lastName(self): return self.name.split()[-1] def giveRaise(self, percent): self.pay*=(1.0+percent) Then the book says "Calling the class like a function generates instances of a new type ...etc" and gives this example. bob = Worker('Bob Smith', 50000) This gives me this error: TypeError: this constructor takes no arguments. And then I start muttering profanities. So what am I doing wrong here? Thanks for the help.

    Read the article

  • ASP.NET MVC WAP, SharePoint Designer and SVN

    - by David Lively
    All, I'm starting a new ASP.NET MVC project which requires some content management capabilities. The people who will be managing the content prefer to use SharePoint Designer (successor to FrontPage) to modify content. I'd like to allow them to keep doing that. The issues are: Since I'd like this to be a WAP, not a website project, how can I allow them to see their changes in action without requiring them to have Visual Studio on their local machines? Can I specify a "default" action for a controller so that given a url like /products/new_view_here Can I let them save pages (views) and see them in the browser without having to go through the check-in/build/deploy process? I'd like their changes to be stored in SVN; SharePoint designer seems to only support Visual SourceSafe (ugh) directly. The ideas I've come up with so far are Write an HTTP handler that implements the FrontPage Server Extensions protocol. This sounds time consuming, but I haven't yet looked at the protocol spec. However, it would allow me to perform whatever operations I want on the server side, including checking files into SVN. Ditch the WAP in favor of a website project. I do not like having the source present on the server, however. Also, will MVC work in a website project? Surely someone has tackled this problem before?

    Read the article

  • WCF Multiple Services

    - by David
    Hi, im brand spanking new to WCF and Im trying to understand how to correctly expose my BLL to it. I created my first Resource.svc and IResource.svc Resource.svc [ServiceBehavior] public class Resources : IResources { #region IResources Members public List<Model.Resource> GetAll() { return Repository.Inventory.Resource.GetAll(true); } public List<Model.Resource> GetAllEnabled() { return Repository.Inventory.Resource.GetAllEnabled(true); } #endregion } IResource.cs [ServiceContract] public interface IResources { [OperationContract] List<Model.Resource> GetAll(); [OperationContract] List<Model.Resource> GetAllEnabled(); } So this all works, My windows app can talk to the service and all is great. So I now need to access some information, I have created another .svc file called Project.svc and IProject.cs, this contains the same info as resource (apart from the type is Project) But this now means I have another webservice, surley this is not right!?

    Read the article

  • ColdFusion CFC implementation of C# Partial Class?

    - by Brian David Berman
    Does ColdFusion offer a mechanism for splitting CFCs into multiple files? I am NOT talking about extension, I am talking about splitting the SAME CFC into multiple files; the same way C# allows for "partial" classes. The reason for this is because I am using T4 to generate a bunch of CFCs and I want to be able to tag functionality onto the generated CFC by doing so in another file. I want to do this in a way that doesn't violate the Open-Closed Principle.

    Read the article

  • SQLAlchemy custom sorting algorithms when using SQL indexes

    - by David M
    Is it possible to write custom collation functions with indexes in SQLAlchemy? SQLite for example allows specifying the sorting function at a C level as sqlite3_create_collation(). An implementation of some of the Unicode collation algorithm has been provided by James Tauber here, which for example sorts all the "a"'s close together whether they have accents on them or not. Other examples of why this might be useful is for different alphabet orders (languages other than English) and sorting numeric values (sorting 10 after 9 rather than codepoint order.) Is this possible in SQLAlchemy? If not, is it supported by the pysqlite3 or MySQLdb modules, or for any other SQL database modules supported by python for that matter? Any information would be greatly appreciated.

    Read the article

  • Enums, Constructor overloads with similar conversions.

    - by David Thornley
    Why does VisualC++ (2008) get confused 'C2666: 2 overloads have similar conversions' when I specify an enum as the second parameter, but not when I define a bool type? Shouldn't type matching already rule out the second constructor because it is of a 'basic_string' type? #include <string> using namespace std; enum EMyEnum { mbOne, mbTwo }; class test { public: #if 1 // 0 = COMPILE_OK, 1 = COMPILE_FAIL test(basic_string<char> myString, EMyEnum myBool2) { } test(bool myBool, bool myBool2) { } #else test(basic_string<char> myString, bool myBool2) { } test(bool myBool, bool myBool2) { } #endif }; void testme() { test("test", mbOne); } I can work around this by specifying a reference 'ie. basic_string &myString' but not if it is 'const basic_string &myString'. Also calling explicitly via "test((basic_string)"test", mbOne);" also works. I suspect this has something to do with every expression/type being resolved to a bool via an inherent '!=0'. Curious for comments all the same :)

    Read the article

  • Using c# System.DateTime like c++ time_t

    - by David Boland
    In C++ I am able to get the current time when my application starts I can use time_t appStartTime = time(null); then to find the difference in seconds from when it started I can just do the same thing, then find the difference. It looks like I should be using "System.DateTime" in C# net, but the MSDN is confusing in its explanation. How can I use System.DateTime to find the difference in time (in seconds) between when my application starts, and the current time?

    Read the article

  • Execute Oracle RAC cluster commands via Solaris RBAC?

    - by David Citron
    Executing Oracle RAC cluster management commands such as $ORA_CRS_HOME/bin/crs_start requires root permissions. Using Solaris RBAC (Role-Based Access Control), one can give a non-root user permissions to execute those commands, but the commands still fail internally. Example: $pfexec /opt/11.1.0/crs/bin/crs_stop SomeArg CRS-0259: Owner of the resource does not belong to the group. Is there a complete RBAC solution for Oracle RAC or does the executor need to be root? EDIT: Note that my original /etc/security/exec_attr contained: MyProfile:suser:cmd:::/opt/11.1.0/crs/bin/crs_start:uid=0 MyProfile:suser:cmd:::/opt/11.1.0/crs/bin/crs_start.bin:uid=0 As Martin suggests below, this needed to be changed to add gid=0 as: MyProfile:suser:cmd:::/opt/11.1.0/crs/bin/crs_start:uid=0;gid=0 MyProfile:suser:cmd:::/opt/11.1.0/crs/bin/crs_start.bin:uid=0;gid=0

    Read the article

  • Single HTML Table from multiple MySQL tables

    - by David Chouinard
    Hi! I've been struggling for a while with this one; I'll try to explain it here as simply as possible. Consider this MySQL table: +----------+-----------+---------+--------+ |status_id |session_id |pilot_id |present | +----------+-----------+---------+--------+ |1 |61 |901 |1 | |2 |63 |901 |1 | |3 |62 |901 |0 | |4 |62 |902 |1 | |5 |63 |903 |1 | +----------+-----------+---------+--------+ Both session_id and pilot_id are foreign keys making reference to a primary key in another table. The same pilot_id can be associated with different session_id, but every pilot_id-session_id combination is unique. I need to make an HTML table (in PHP) that would display the data like this: +----------+---------+---------+---------+ | |61 |62 |63 | +----------+---------+---------+---------+ |901 |X | |X | |902 | |X | | |903 | | |X | +----------+---------+---------+---------+ Hence, rows are pilot_id and columns are session_id. When a pilot_id-session_id combination has a present value of 1, the corresponding cell should be checked. (ie. when the row-combination is zero or the combination does not exist in the MySQL table, nothing should appear in the HTML table) Phew. Any ideas? Thanks!

    Read the article

  • Event handling for keyboard strokes

    - by david
    Hey, I'm trying to get familiar with the whole keyboard event detection thing. Here's my sample code. <fx:Script> <![CDATA[ import flash.events.KeyboardEvent; import mx.controls.Alert; private function init():void{ addEventListener(KeyboardEvent.KEY_DOWN,reportKeyDown); } private function reportKeyDown(event:KeyboardEvent):void { Alert.show("a key was pressed"); } ]]> </fx:Script> As you can see, I'm at stage 0 of playing around with it, but it won't work. Anyone has any idea what I should be doing instead? Thanks

    Read the article

  • Editing a Gridview row with drop-down lists gets too wide - how can I use popup panels instead?

    - by David
    I have a series of GridViews in a Tab Panel - databound to a generic List of Business Objects. The columns in the Gridview are all similar to the following: <asp:TemplateField HeaderText="Company" SortExpression="Company.ShortName"> <ItemTemplate> <asp:Label ID="lblCompany" runat="server" Text='<%# Bind("Company.ShortName") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:DropDownList ID="ddlCompany" runat="server"></asp:DropDownList> </EditItemTemplate> </asp:TemplateField> The GridView generates the "Edit" link at the beginning of the row, all the events fire ok. The problem is that the data is getting long. When in 'display mode', it's fine because the GridView control is smart enough to break some text into multiple lines (in particular Project, Title and Worker names can get pretty long). The problem come in editing mode. Drop-down lists DON'T break entries into multiple lines (for obvious reasons). Going into Edit ode on a row in the Gridview can make the Griview expand horizontally to twice the screen size (blowing through the width limits in the Master page and CSS but that's only a related problem). What I need is something like the ModalPopup - but trying to tie it to an ID in an EditItemTemplate gives me errors when the page renders (because the 'ddlXXXX' doesn't exist at the time). In addition I don't know how to dynamically populate the panel so that I can get a response from it (like the ID of the Company they selected). I'm also trying to avoid javascript and would like this to be a 'pure' aspx/code-behind solution (for simplicity's sake among others). All the examples I find are of Modal Popups with the panels pre-defined. Even if it (the popup panel) were something like a list of checkboxes, it could be databound to the SortedList I have ready to go and an OK/Cancel button combination to accept or ignore things. I'm just not sure of what goes where. I'm open to suggestions. Thanks in advance. EDIT: Final solution looks as follows: <asp:TemplateField HeaderText="Company" SortExpression="Company.ShortName"> <ItemTemplate> <asp:Label ID="lblCompany" runat="server" Text='<%# Bind("Company.ShortName") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:LinkButton ID="lnkCompany" runat="server" Text='<%# Bind("Company.ShortName") %>'></asp:LinkButton> <asp:Panel ID="pnlCompany" runat="server" style="display:none"> <div> <asp:DropDownList ID="ddlCompany" runat="server" ></asp:DropDownList> <br/> <asp:ImageButton ID="btnOKCo" runat="server" ImageUrl="~/Images/greencheck.gif" OnCommand="PopupButton_Command" CommandName="SelectCO" /> <asp:ImageButton ID="btnCxlCo" runat="server" ImageUrl="~/Images/RedX.gif" /> </div> </asp:Panel> <cc1:ModalPopupExtender ID="mpeCompany" runat="server" TargetControlID="lnkCompany" PopupControlID="pnlCompany" BackgroundCssClass="modalBackground" CancelControlID="btnCxlCo" DropShadow="true" PopupDragHandleControlID="pnlCompany" /> </EditItemTemplate> </asp:TemplateField> And in the code-behind, lstIDLabor is the generic List of data lines (of which Company is one of the properties that is also a business object) that is bound to the GridView: Sub PopupButton_Command(ByVal sender As Object, ByVal e As CommandEventArgs) Dim intRow As Integer Dim intVal As Integer RestoreFromSessionVariables() Select Case e.CommandName Case "SelectCO" intRow = grdIDCostLabor.EditIndex Dim ddlCo As DropDownList = CType(grdIDCost.Rows(intRow).FindControl("ddlCompany"), DropDownList) intVal = ddlCo.SelectedValue lstIDLabor(intRow).CompanyID = intVal lstIDLabor(intRow).Company = Company.Read(intVal) Case Else ' End Select MakeSessionVariables() BindGrids() End Sub

    Read the article

  • What adapter to use for ExpandableListView with non-TextView views?

    - by David
    I have an ExpandableListView in which I'd like to have controls other than TextView. Apparently, SimpleExandableListViewAdapter assumes all the controls are TextViews. A cast exception is generated if they are not. What is the recommended solution? Options I can think of include: - Use some other included adapter. But I can't tell if they all have the same assumption. - Create my own adapter. Is there a doc which describes the contract, ie the sequence of method calls an adapter will encounter? I expected the existing adapters to require the views to conform to some interface to allow any conforming view to be used, rather than hardcode to textview and limit where they can be used.

    Read the article

  • javascript change innerhtml

    - by David
    ok im new at javascript, but im trying to change the innerhtml of a div tag, heres my script and its not working: <head> <script type="text/javascript"> function var1() { document.getElementById('test').innerHTML = 'hi'; } window.onLoad = var1(); </script> </head> <body> <div id="test">change</div> </body> it should work but for some reason its not, any help?

    Read the article

  • Is there a way to change the maximum width of a window without using the WM_GETMINMAXINFO message?

    - by David
    I want to change the imposed Windows maximum width that a window can be resized to, for an external application's window (not my C#/WinForms program's window). The documentation of GetSystemMetrics for SM_CXMAXTRACK says: "The default maximum width of a window that has a caption and sizing borders, in pixels. This metric refers to the entire desktop. The user cannot drag the window frame to a size larger than these dimensions. A window can override this value by processing the WM_GETMINMAXINFO message." Is there a way to modify this SM_CXMAXTRACK value (either system wide or for one particular window), without processing the WM_GETMINMAXINFO message? Maybe an undocumented function, a registry setting, etc.? (Or: The documentation for MINMAXINFO.ptMaxTrackSize says: "This value is based on the size of the virtual screen and can be obtained programmatically from the system metrics SM_CXMAXTRACK and SM_CYMAXTRACK." Maybe there is a way to change the size of the virtual screen?) Thank you

    Read the article

  • jQuery UI - Datepicker - Hide year

    - by David
    Hi, I'm using jQuery UI 1.8 and I would like to hide the year from the user in both the popup and the textbox. Essentially instead of picking the day, month and year I want the user to just pick the day and month. Hiding the year in the textbox is easy enough, the code shown below will do that. I'm stumped on how to hide the year from the popup - so it would say "April" instead of "April 2010". $(function() { $("#beginDateRange").datepicker({ dateFormat: 'mm/dd' }); }); <input type="text" name="beginDateRange" id="beginDateRange" /> Any help would be greatly appreciated.

    Read the article

  • CodeCharge : is it any good?

    - by David Burrows
    Hi, A job came in to me that's built with CodeCharge - had a look at it and seems to be a pretty basic point-and-click site builder tool. Has anyone got any in-depth experience with it? My first reaction is one of horror and to just rebuild the code in Rails or PHP but I thought I'd ask the question first, maybe i'm missing something...

    Read the article

< Previous Page | 76 77 78 79 80 81 82 83 84 85 86 87  | Next Page >