Search Results

Search found 5192 results on 208 pages for 'random forests'.

Page 40/208 | < Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >

  • How can I test a form that requires the entry of two random characters from a security phrase?

    - by lawm
    I need to test a two-stage login system which first asks for your email address and password and then presents the user with two select lists containing [a-zA-Z0-9]. The labels beside the drop down's are of the form 'Select character X from your security phrase', where X is a random character index from a known security phrase. I'd rather not stub the code for an acceptance test, so is it possible to write a matcher in cucumber which will, given that we know the whole phrase, select the required character in each of the two lists? Here is the scenario I have so far and the steps involved: Scenario: valid login email, password and secret phrase takes me to the dashboard Given I am not logged in When I log in as "[email protected]" Then I should be on the dashboard page And I should see "Your Dashboard" When /^I log in as "([^\"]*)"$/ do |login| visit path_to('Login page') fill_in "Email", :with => login fill_in "Password", :with => "Password123" click_button "Log in" response.should contain("Please verify some characters from your security phrase") select "a", :from => "Select character X of your security phrase" select "b", :from => "Select character Y of your security phrase" click_button "Submit" end For example, if the security phrase is 'Secret123', X = 3 and Y = 8, the above would have to produce the equivalent of: select "c", :from => "Select character 3 of your security phrase" select "2", :from => "Select character 8 of your security phrase" The numbers X and Y in the actual page are inside span#svc_1 and span#svc_2 respectively. Thanks,

    Read the article

  • How to change one Button background in a gridview? -- Android

    - by Tstop Studios
    I have a GridView with 16 ImageView buttons. My program makes a random number and when the user clicks a button in the gridview, i want it to take the random number (0-15) and set the background of the tile with the same position as the random number (0-15) to a different image. How can I just change one of the buttons background? Here's my code so far: public class ButtonHider extends Activity { Random random = new Random(); int pos; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.button_hider); pos = random.nextInt(15); GridView gridview = (GridView) findViewById(R.id.gvBH); gridview.setAdapter(new ImageAdapter(this)); gridview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { pos = random.nextInt(16); if (position == pos) { Toast.makeText(ButtonHider.this, "Found Me!", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(ButtonHider.this, "Try Again!!", Toast.LENGTH_SHORT).show(); } } }); } public class ImageAdapter extends BaseAdapter { private Context mContext; public ImageAdapter(Context c) { mContext = c; } public int getCount() { return 16; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } // create a new ImageView for each item referenced by the Adapter public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView; if (convertView == null) { // if it's not recycled, initialize some // attributes imageView = new ImageView(mContext); imageView.setLayoutParams(new GridView.LayoutParams(100, 100)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(15, 15, 15, 15); } else { imageView = (ImageView) convertView; } imageView.setImageResource(R.drawable.bh_b); return imageView; } } }

    Read the article

  • c# multi inheritance

    - by user326839
    So ive got a base class which requires a Socket: class Sock { public Socket s; public Sock(Socket s) { this.s = s; } public virtual void Process(byte[] data) { } ... } then ive got another class. if a new socket gets accepted a new instance of this class will be created: class Game : Sock { public Random Random = new Random(); public Timerr Timers; public Test Test; public Game(Socket s) : base(s) { } public static void ReceiveNewSocket(object s) { Game Client = new Game((Socket)s); Client.Start(); } public override void Process(byte[] buf) { Timers = new Timerr(s); Test = new Test(s); Test.T(); } } in the Sock class ive got a virtual function that gets overwritten by the Game class.(Process function) in this function im calling a function from the Test Class(Test+ Timerr Class: class Test : Game { public Test(Socket s) : base(s) { } public void T() { Console.WriteLine(Random.Next(0, 10)); Timers.Start(); } } class Timerr : Game { public Timerr(Socket s) : base(s) { } public void Start() { Console.WriteLine("test"); } } ) So in the Process function im calling a function in Test. And in this function(T) i need to call a function from the Timerr Class.But the problem is its always NULL , although the constructor is called in Process. And e.g. the Random Class can be called, i guess its because its defined with the constructor.: public Random Random = new Random(); and thats why the other classes(without a constructor): public Timerr Timers; public Test Test; are always null in the inherited class Test.But its essentiel that i call other Methods of other classes in this function.How could i solve that?

    Read the article

  • Thunderbird: how to move mails into correct thread? (mailing lists)

    - by unor
    I'm subscribed to some mailing lists and every day people reply to a wrong mail (or they don't reply at all), so that their mail lands in the wrong (or a new) thread. I set the mail display in "View ? Sort by" to "Threaded". Example: mailing list "Foobar": [Foobar] random topic Re: [Foobar] random topic Re: [Foobar] random topic Re: [Foobar] random topic Re: [Foobar] random topic [Foobar] I'm John Doe Re: [Foobar] I'm John Doe Re: [Foobar] Welcome, John Re: [Foobar] random topic There are two discussions, one about "random topic", one about "John Doe". The subject line changes in the discussion about John Doe, which is fine (no problem here). But the last mail should be pigeonholed in the first thread. Instead it is at the top-level. Now, how can I move that last mail into the correct thread? I tried to drag&drop it at the mail I think it should be a reply to, but this doesn't work. I think theoretically it should be possible by fiddling with the mail headers after receiving the mail, but this doesn't seem to be a comfortable way.

    Read the article

  • Linq to SQL NullReferenceException's: A random needle in a haystack!

    - by Shane
    I'm getting NullReferenceExeceptions at seemly random times in my application and can't track down what could be causing the error. I'll do my best to describe the scenario and setup. Any and all suggestions greatly appreciated! C# .net 3.5 Forms Application, but I use the WebFormRouting library built by Phil Haack (http://haacked.com/archive/2008/03/11/using-routing-with-webforms.aspx) to leverage the Routing libraries of .net (usually used in conjunction with MVC) - intead of using url rewriting for my urls. My database has 60 tables. All Normalized. It's just a massive application. (SQL server 2008) All queries are built with Linq to SQL in code (no SP's). Each time a new instance of my data context is created. I use only one data context with all relationships defined in 4 relationship diagrams in SQL Server. the data context gets created a lot. I let the closing of the data context be handled automatically. I've heard arguments both sides about whether you should leave to be closed automatically or do it yourself. In this case I do it myself. It doesnt seem to matter if I'm creating a lot of instances of the data context or just one. For example, I've got a vote-up button. with the following code, and it errors probably 1 in 10-20 times. protected void VoteUpLinkButton_Click(object sender, EventArgs e) { DatabaseDataContext db = new DatabaseDataContext(); StoryVote storyVote = new StoryVote(); storyVote.StoryId = storyId; storyVote.UserId = Utility.GetUserId(Context); storyVote.IPAddress = Utility.GetUserIPAddress(); storyVote.CreatedDate = DateTime.Now; storyVote.IsDeleted = false; db.StoryVotes.InsertOnSubmit(storyVote); db.SubmitChanges(); // If this story is not yet published, check to see if we should publish it. Make sure that // it is already approved. if (story.PublishedDate == null && story.ApprovedDate != null) { Utility.MakeUpcommingNewsPopular(storyId); } // Refresh our page. Response.Redirect("/news/" + category.UniqueName + "/" + RouteData.Values["year"].ToString() + "/" + RouteData.Values["month"].ToString() + "/" + RouteData.Values["day"].ToString() + "/" + RouteData.Values["uniquename"].ToString()); } The last thing I tried was the "Auto Close" flag setting on SQL Server. This was set to true and I changed to false. Doesnt seem to have done the trick although has had a good overall effect. Here's a detailed that wasnt caught. I also get slighly different errors when caught by my try/catch's. System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. --- System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.Util.StringUtil.GetStringHashCode(String s) at System.Web.UI.ClientScriptManager.EnsureEventValidationFieldLoaded() at System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) at System.Web.UI.WebControls.TextBox.LoadPostData(String postDataKey, NameValueCollection postCollection) at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace --- at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.forms_news_detail_aspx.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) HELP!!!

    Read the article

  • "LNK2001: unresolved external symbol" when trying to build my program

    - by random
    I get the following error(s) on my program that captures the mouse and then draws a line. Errors: 1>------ Build started: Project: Capture_Mouse_Line, Configuration: Debug Win32 ------ 1> main.cpp 1>main.obj : error LNK2001: unresolved external symbol "public: static long * Line::yc2" (?yc2@Line@@2PAJA) 1>main.obj : error LNK2001: unresolved external symbol "public: static long * Line::xc2" (?xc2@Line@@2PAJA) 1>main.obj : error LNK2001: unresolved external symbol "public: static long * Line::yc1" (?yc1@Line@@2PAJA) 1>main.obj : error LNK2001: unresolved external symbol "public: static long * Line::xc1" (?xc1@Line@@2PAJA) 1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup 1>D:\Visual C++ Projects\Capture_Mouse_Line\Debug\Capture_Mouse_Line.exe : fatal error LNK1120: 5 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Here is my code: #include<allegro5\allegro.h> #include<allegro5\allegro_native_dialog.h> #include<allegro5\allegro_primitives.h> #include<Windows.h> #include<allegro5\allegro_windows.h> #ifndef WIDTH #define WIDTH 1440 #endif #ifndef HEIGHT #define HEIGHT 900 #endif class Line { public: static void ErasePreviousLine(); static void DrawLine(long* x, long* y,long* x2,long* y2); static bool Erasable(); static long* xc1; static long* yc1; static long* xc2; static long* yc2; }; void Line::ErasePreviousLine() { delete xc1; xc1 = NULL; delete yc1; yc1 = NULL; delete xc2; xc2 = NULL; delete yc2; yc2 = NULL; } bool Line::Erasable() { if(xc1 && yc1 && xc2 && yc2 == NULL) { return false; } else { return true; } } void Line::DrawLine(long* x,long* y,long* x2,long* y2) { if(!al_init_primitives_addon()) { al_show_native_message_box(NULL,NULL,NULL,"failed to initialize allegro", NULL,NULL); } xc1 = x; yc1 = y; xc2 = x2; yc2 = y2; al_draw_line((float)*xc1, (float)*yc1, (float)*xc2, (float)*yc2,al_map_rgb(255,0,255), 1); delete x; delete y; delete x2; delete y2; } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG msg; ALLEGRO_DISPLAY* display = NULL; if(!al_init()) { al_show_native_message_box(NULL,NULL,NULL,"failed to initialize allegro", NULL,NULL); return -1; } display = al_create_display(WIDTH,HEIGHT); if(!display) { al_show_native_message_box(NULL,NULL,NULL,"failed to initialize display", NULL,NULL); return -1; } HWND hwnd = al_get_win_window_handle(display); if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); while(GetMessage(&msg, NULL, 0, 0) > 0) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { static bool bIsCaptured; static POINTS ptsBegin; static POINTS ptsEnd; switch(msg) { case WM_LBUTTONDOWN: SetCapture(hwnd); bIsCaptured = true; ptsBegin = MAKEPOINTS(lParam); return 0; case WM_MOUSEMOVE: if(wParam & MK_LBUTTON) { if(!Line::Erasable()) { return 0; } Line::ErasePreviousLine(); ptsEnd = MAKEPOINTS(lParam); Line::DrawLine(new long(ptsBegin.x),new long(ptsBegin.y),new long(ptsEnd.x),new long(ptsEnd.y)); } break; case WM_LBUTTONUP: bIsCaptured = false; ReleaseCapture(); break; case WM_ACTIVATEAPP: { if(wParam == TRUE) { if(bIsCaptured){ SetCapture(hwnd);} } } break; } return 0; }

    Read the article

  • How to remove a tagged block of text in a file?

    - by EmpireJones
    How can I remove all instances of tagged blocks of text in a file with sed, grep, or another program? If I have a file which contains: random text // START TEXT internal text // END TEXT more random // START TEXT asdf // END TEXT text how can I remove all blocks of text within the start/end lines, produce the following? random text more random text

    Read the article

  • Python performance: iteration and operations on nested lists

    - by J.J.
    Problem Hey folks. I'm looking for some advice on python performance. Some background on my problem: Given: A mesh of nodes of size (x,y) each with a value (0...255) starting at 0 A list of N input coordinates each at a specified location within the range (0...x, 0...y) Increment the value of the node at the input coordinate and the node's neighbors within range Z up to a maximum of 255. Neighbors beyond the mesh edge are ignored. (No wrapping) BASE CASE: A mesh of size 1024x1024 nodes, with 400 input coordinates and a range Z of 75 nodes. Processing should be O(x*y*Z*N). I expect x, y and Z to remain roughly around the values in the base case, but the number of input coordinates N could increase up to 100,000. My goal is to minimize processing time. Current results I have 2 current implementations: f1, f2 Running speed on my 2.26 GHz Intel Core 2 Duo with Python 2.6.1: f1: 2.9s f2: 1.8s f1 is the initial naive implementation: three nested for loops. f2 is replaces the inner for loop with a list comprehension. Code is included below for your perusal. Question How can I further reduce the processing time? I'd prefer sub-1.0s for the test parameters. Please, keep the recommendations to native Python. I know I can move to a third-party package such as numpy, but I'm trying to avoid any third party packages. Also, I've generated random input coordinates, and simplified the definition of the node value updates to keep our discussion simple. The specifics have to change slightly and are outside the scope of my question. thanks much! f1 is the initial naive implementation: three nested for loops. 2.9s def f1(x,y,n,z): rows = [] for i in range(x): rows.append([0 for i in xrange(y)]) for i in range(n): inputX, inputY = (int(x*random.random()), int(y*random.random())) topleft = (inputX - z, inputY - z) for i in xrange(max(0, topleft[0]), min(topleft[0]+(z*2), x)): for j in xrange(max(0, topleft[1]), min(topleft[1]+(z*2), y)): if rows[i][j] <= 255: rows[i][j] += 1 f2 is replaces the inner for loop with a list comprehension. 1.8s def f2(x,y,n,z): rows = [] for i in range(x): rows.append([0 for i in xrange(y)]) for i in range(n): inputX, inputY = (int(x*random.random()), int(y*random.random())) topleft = (inputX - z, inputY - z) for i in xrange(max(0, topleft[0]), min(topleft[0]+(z*2), x)): l = max(0, topleft[1]) r = min(topleft[1]+(z*2), y) rows[i][l:r] = [j+1 for j in rows[i][l:r] if j < 255]

    Read the article

  • .NET pie chart: how to add text to slices and rotate chart

    - by Sajee
    The code below creates a 24 slice pie chart. How do I: Add text labels to each slice a la "Wheel of Fortune". Rotate the pie chart? I want it to spin like "Wheel of Fortune". private void DrawPieChart() { Graphics g = this.CreateGraphics(); g.Clear(this.BackColor); Rectangle rect = new Rectangle(0, 0, 300, 300); float angle = 0; Random random = new Random(); int sectors = 24; int sweep = 360 / sectors; for(int i=0; i&lt;24;i++) { Color clr = Color.FromArgb(random.Next(0, 255),random.Next(0, 255), random.Next(0, 255)); g.FillPie(new SolidBrush(clr), rect, angle, sweep); angle += sweep; } g.Dispose(); }

    Read the article

  • How do I name an array key with a key inside the array

    - by Confused
    I have some data, yes, data. This data came from a MySQL query and it will always contain 4 items, always. I want to cache that data in an array table for use later within a web page but I want to keep the keys from the query and separate out each grouping within a multidimensional array. However to save time iterating through the array each time I want to find a given group of data, I want to call the keys of the first array the same as the ID key which is always the first key within each four items. At the minute I'm using this code: function mysql_fetch_full_result_array($result) { $table_result=array(); $r=0; while($row = mysql_fetch_assoc($result)){ $arr_row=array(); $c=0; while ($c < mysql_num_fields($result)) { $col = mysql_fetch_field($result, $c); $arr_row[$col -> name] = $row[$col -> name]; $c++; } $table_result[$r] = $arr_row; $r++; } return $table_result; } I'm currently testing this using 3 unique users, so I'm getting three rows back from the query and the data from this function ends up in the format: [0]=> . . [id] => 1 . . [name] => random name . . [tel] => random tel . . [post] => post code data [1]=> . . [id] => 34 . . [name] => random name . . [tel] => random tel . . [post] => post code data [2]=> . . [id] => 56 . . [name] => random name . . [tel] => random tel . . [post] => post code data So how do I alter the code to instead of the keys [0], [1], [2] give me the output: [1]=> . . [id] => 1 . . [name] => random name . . [tel] => random tel . . [post] => post code data [34]=> . . [id] => 34 . . [name] => random name . . [tel] => random tel . . [post] => post code data [56]=> . . [id] => 56 . . [name] => random name . . [tel] => random tel . . [post] => post code data I don't mind if the main array keys are strings of numbers rather than numbers but I'm a bit stuck, I tried changing the $table_result[$r] = $arr_row; part to read $table_result[$result['id']] = $arr_row; but that just outputs an array of one person. I know I need another loop but I'm struggling to work out how to write it.

    Read the article

  • Python code that needs some overview

    - by fabio
    Hi guys, im currently learning python (in the very begining), so I still have some doubts about good code manners and how should I proceed with it. Today I created this code that should random trought 01 to 60 (but is running from 01 to 69) import random dez = ['0', '1', '2', '3', '4', '5', '6'] uni = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] sort = [] while len(sort) <= 5: random.shuffle(dez) random.shuffle(uni) w = random.choice(dez) z = random.choice(uni) chosen = str(w) + str(z) if chosen != "00" and chosen not in sort: sort.append(chosen) print chosen I'm also in doubt how to make the code stop at "60".

    Read the article

  • regex to break a string into "key" / "value" pairs when # of pairs is variable?

    - by user141146
    Hi, I'm using Ruby 1.9 and I'm wondering if there's a simple regex way to do this. I have many strings that look like some variation of this: str = "Allocation: Random, Control: Active Control, Endpoint Classification: Safety Study, Intervention Model: Parallel Assignment, Masking: Double Blind (Subject, Caregiver, Investigator, Outcomes Assessor), Primary Purpose: Treatment" The idea is that I'd like to break this string into its functional components Allocation: Random Control: Active Control Endpoint Classification: Safety Study Intervention Model: Parallel Assignment Masking: Double Blind (Subject, Caregiver, Investigator, Outcomes, Assessor) Primary Purpose: Treatment The "syntax" of the string is that there is a "key" which consists of one or more "words or other characters" (e.g. Intervention Model) followed by a colon (:). Each key has a corresponding "value" (e.g., Parallel Assignment) that immediately follows the colon (:)…The "value" consists of words, commas (whatever), but the end of the "value" is signaled by a comma. The # of key/value pairs is variable. I'm also assuming that colons (:) aren't allowed to be part of the "value" and that commas (,) aren't allowed to be part of the "key". One would think that there is a "regexy" way to break this into its component pieces, but my attempt at making an appropriate matching regex only picks up the first key/value pair and I'm not sure how to capture the others. Any thoughts on how to capture the other matches? regex = /(([^,]+?): ([^:]+?,))+?/ => /(([^,]+?): ([^:]+?,))+?/ irb(main):139:0> str = "Allocation: Random, Control: Active Control, Endpoint Classification: Safety Study, Intervention Model: Parallel Assignment, Masking: Double Blind (Subject, Caregiver, Investigator, Outcomes Assessor), Primary Purpose: Treatment" => "Allocation: Random, Control: Active Control, Endpoint Classification: Safety Study, Intervention Model: Parallel Assignment, Masking: Double Blind (Subject, Caregiver, Investigator, Outcomes Assessor), Primary Purpose: Treatment" irb(main):140:0> str.match regex => #<MatchData "Allocation: Random," 1:"Allocation: Random," 2:"Allocation" 3:" Random,"> irb(main):141:0> $1 => "Allocation: Random," irb(main):142:0> $2 => "Allocation" irb(main):143:0> $3 => " Random," irb(main):144:0> $4 => nil

    Read the article

  • What is the best place to display the language in your url

    - by Saif Bechan
    I have a multi-language website that makes use of pretty urls, so called search engine friendly urls. Now there are a few places to define the language in the url. 1) www.mydomain.com/en/articles/random www.mydomain.com/nl/articles/random 2) en.mydomain.com/articles/random nl.mydomain.com/articles/random 3) www.mydomain.com/articles/random?lang=en www.mydomain.com/articles/random?lang=nl Is there any preffered way of showing this, or is there another way better that I did not show. I would like to hear your comments on this.

    Read the article

  • How Can I optimize this RewriteEngine Code?

    - by Lucki Mile
    I have server overload, server admin said that this issue is caused from htaccess file This is the code: RewriteEngine On RewriteBase /here/ RewriteRule ^top/?$ index.php?mode=top [QSA] RewriteRule ^top/video/?$ index.php?mode=top&cat=vids [QSA] RewriteRule ^top/picture/?$ /index.php?mode=top&cat=pics [QSA] RewriteRule ^random$ index.php?mode=random [QSA] RewriteRule ^random/video/?$ index.php?mode=random&cat=vids [QSA] RewriteRule ^random/picture/?$ index.php?mode=random&cat=pics [QSA] RewriteRule ^new/?$ index.php [QSA] RewriteRule ^new/video/?$ index.php?mode=&cat=vids [QSA] RewriteRule ^new/picture/?$ index.php?mode=&cat=pics [QSA] RewriteRule ^video/([0-9]+)_(.*)$ item.php?cat=vids&id=$1 [QSA] RewriteRule ^picture/([0-9]+)_(.*)$ item.php?cat=pics&id=$1 [QSA] ErrorDocument 404 /item.php

    Read the article

  • Randomly choose value between 1 and 10 with equal number of instances

    - by user1723765
    I would like to generate 2000 random numbers between 1 and 10 such that for each random number I have the same number of instances. In this case 200 for each number. What should be random is the order in which it is generated. I have the following problem: I have an array with 2000 entries but not each with unique values, for example it starts like this: 11112233333333344445667777777777 and consists of 2000 entries. I would like to generate random numbers and assign each UNIQUE value a separate random number but have an entry for each value So my intended result would look like this: original array: 11112233333333344445667777777777 random numbers: 33334466666666699991778888888888

    Read the article

  • EXC_BAD_INSTRUCTION (SIGILL) at random during use of app. Bug in AppKit?

    - by Ger Teunis
    I'm currently testing a new version of an app of mine on OSX 10.5 An user reported some weird crashes during use of the application, sadly not reproducible by me. At first sight it seems to happen randomly, once he had the crash while opening an NSOpenPanel and once during focusing an NSTextField and once during NSView switch in a parent view. If you have any idea which area I should look at it would be greatly appreciated! I'm completely lost here. App is compiled in XCode 3.2.1 with SDK 10.5 and targetted at 10.5 He send me these crashes: Crash 1 Process: NZBVortex [43622] Path: /Users/cero/Downloads/NZBVortex.app/Contents/MacOS/NZBVortex Identifier: com.NZBVortex.NZBVortex Version: 0.5.5 (0.5.5) Code Type: X86-64 (Native) Parent Process: launchd [97] Interval Since Last Report: 1951 sec Crashes Since Last Report: 1 Per-App Interval Since Last Report: 1858 sec Per-App Crashes Since Last Report: 1 Date/Time: 2010-03-23 23:43:49.671 +0100 OS Version: Mac OS X 10.5.8 (9L31a) Report Version: 6 Anonymous UUID: 98AB0386-590B-4E0D-B7AC-3F7AA4E7238E Exception Type: EXC_BAD_INSTRUCTION (SIGILL) Exception Codes: 0x0000000000000001, 0x0000000000000000 Crashed Thread: 0 Application Specific Information: objc[43622]: alt handlers in objc runtime are buggy! - Hide quoted text - Thread 0 Crashed: 0 libobjc.A.dylib 0x00007fff82baef6e _objc_fatal + 238 1 libobjc.A.dylib 0x00007fff82bb2ea4 objc_addExceptionHandler + 302 2 com.apple.CoreFoundation 0x00007fff842b1090 _CFDoExceptionOperation + 528 3 com.apple.AppKit 0x00007fff81f75e26 _NSAppKitLock + 81 4 com.apple.AppKit 0x00007fff81f80f8f -[NSView nextKeyView] + 56 5 com.apple.AppKit 0x00007fff81f81018 -[NSView _primitiveSetNextKeyView:] + 72 6 com.apple.AppKit 0x00007fff820732b1 -[NSView _recursiveSetDefaultKeyViewLoop] + 242 7 com.apple.AppKit 0x00007fff82073300 -[NSView _recursiveSetDefaultKeyViewLoop] + 321 8 com.apple.AppKit 0x00007fff82073300 -[NSView _recursiveSetDefaultKeyViewLoop] + 321 9 com.apple.AppKit 0x00007fff82073300 -[NSView _recursiveSetDefaultKeyViewLoop] + 321 10 com.apple.AppKit 0x00007fff82073300 -[NSView _recursiveSetDefaultKeyViewLoop] + 321 11 com.apple.AppKit 0x00007fff82072fc3 -[NSView _setDefaultKeyViewLoop] + 279 12 com.apple.AppKit 0x00007fff82072e70 -[NSWindow recalculateKeyViewLoop] + 36 13 com.apple.AppKit 0x00007fff821dd149 -[NSSavePanel(NSSavePanelRuntime) _loadPreviousModeAndLayout] + 39 14 com.apple.AppKit 0x00007fff821dcf9e -[NSSavePanel(NSSavePanelRuntime) runModalForDirectory:file:types:] + 71 15 com.NZBVortex.NZBVortex 0x000000010000b7ee -[MainWindowViewController openNZBFileButtonClick:] + 62 16 com.apple.AppKit 0x00007fff821c96bf -[NSToolbarButton sendAction:to:] + 77 17 com.apple.AppKit 0x00007fff821c8bb7 -[NSToolbarItemViewer mouseDown:] + 5362 18 com.apple.AppKit 0x00007fff82082783 -[NSWindow sendEvent:] + 5068 19 com.apple.AppKit 0x00007fff8204fd46 -[NSApplication sendEvent:] + 5089 20 com.apple.AppKit 0x00007fff81faa562 -[NSApplication run] + 497 21 com.apple.AppKit 0x00007fff81f772f0 NSApplicationMain + 373 22 com.NZBVortex.NZBVortex 0x0000000100012a69 main + 9 23 com.NZBVortex.NZBVortex 0x0000000100001a84 start + 52 Crash 2 Process: NZBVortex [43600] Path: /Users/cero/Downloads/NZBVortex.app/Contents/MacOS/NZBVortex Identifier: com.NZBVortex.NZBVortex Version: 0.5.5 (0.5.5) Code Type: X86-64 (Native) Parent Process: launchd [97] Interval Since Last Report: 727 sec Crashes Since Last Report: 1 Per-App Interval Since Last Report: 616 sec Per-App Crashes Since Last Report: 1 Date/Time: 2010-03-23 23:11:20.000 +0100 OS Version: Mac OS X 10.5.8 (9L31a) Report Version: 6 Anonymous UUID: 98AB0386-590B-4E0D-B7AC-3F7AA4E7238E Exception Type: EXC_BAD_INSTRUCTION (SIGILL) Exception Codes: 0x0000000000000001, 0x0000000000000000 Crashed Thread: 0 Application Specific Information: objc[43600]: alt handlers in objc runtime are buggy! Thread 0 Crashed: 0 libobjc.A.dylib 0x00007fff82baef6e _objc_fatal + 238 1 libobjc.A.dylib 0x00007fff82bb2ea4 objc_addExceptionHandler + 302 2 com.apple.CoreFoundation 0x00007fff842b1090 _CFDoExceptionOperation + 528 3 com.apple.AppKit 0x00007fff81f75e26 _NSAppKitLock + 81 4 com.apple.AppKit 0x00007fff81f80f8f -[NSView nextKeyView] + 56 5 com.apple.AppKit 0x00007fff81f81018 -[NSView _primitiveSetNextKeyView:] + 72 6 com.apple.AppKit 0x00007fff820732b1 -[NSView _recursiveSetDefaultKeyViewLoop] + 242 7 com.apple.AppKit 0x00007fff82156700 -[NSTabView _recursiveSetDefaultKeyViewLoop] + 119 8 com.apple.AppKit 0x00007fff82073300 -[NSView _recursiveSetDefaultKeyViewLoop] + 321 9 com.apple.AppKit 0x00007fff82073300 -[NSView _recursiveSetDefaultKeyViewLoop] + 321 10 com.apple.AppKit 0x00007fff82072fc3 -[NSView _setDefaultKeyViewLoop] + 279 11 com.apple.AppKit 0x00007fff82072e70 -[NSWindow recalculateKeyViewLoop] + 36 12 com.NZBVortex.NZBVortex 0x000000010000b527 -[MainWindowViewController showView:sender:] + 1639 13 com.NZBVortex.NZBVortex 0x000000010000ae6b -[MainWindowViewController preferencesSaveAlertDidEnd:returnCode:contextInfo:] + 91 14 com.apple.AppKit 0x00007fff82224291 -[NSAlert didEndAlert:returnCode:contextInfo:] + 107 15 com.apple.AppKit 0x00007fff82224197 -[NSAlert buttonPressed:] + 279 16 com.apple.AppKit 0x00007fff82085d46 -[NSApplication sendAction:to:from:] + 97 17 com.apple.AppKit 0x00007fff82085c7f -[NSControl sendAction:to:] + 97 18 com.apple.AppKit 0x00007fff820851b0 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 1841 19 com.apple.AppKit 0x00007fff820849d6 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 611 20 com.apple.AppKit 0x00007fff8208422f -[NSControl mouseDown:] + 735 21 com.apple.AppKit 0x00007fff82082783 -[NSWindow sendEvent:] + 5068 22 com.apple.AppKit 0x00007fff8204fd46 -[NSApplication sendEvent:] + 5089 23 com.apple.AppKit 0x00007fff81faa562 -[NSApplication run] + 497 24 com.apple.AppKit 0x00007fff81f772f0 NSApplicationMain + 373 25 com.NZBVortex.NZBVortex 0x0000000100012a69 main + 9 26 com.NZBVortex.NZBVortex 0x0000000100001a84 start + 52 Crash 3 Process: NZBVortex [43520] Path: /Users/cero/Downloads/NZBVortex.app/Contents/MacOS/NZBVortex Identifier: com.NZBVortex.NZBVortex Version: 0.5.5 (0.5.5) Code Type: X86-64 (Native) Parent Process: launchd [97] Interval Since Last Report: 23487 sec Crashes Since Last Report: 2 Per-App Interval Since Last Report: 2025 sec Per-App Crashes Since Last Report: 1 Date/Time: 2010-03-23 22:59:05.484 +0100 OS Version: Mac OS X 10.5.8 (9L31a) Report Version: 6 Anonymous UUID: 98AB0386-590B-4E0D-B7AC-3F7AA4E7238E Exception Type: EXC_BAD_INSTRUCTION (SIGILL) Exception Codes: 0x0000000000000001, 0x0000000000000000 Crashed Thread: 0 Application Specific Information: objc[43520]: alt handlers in objc runtime are buggy! Thread 0 Crashed: 0 libobjc.A.dylib 0x00007fff82baef6e _objc_fatal + 238 1 libobjc.A.dylib 0x00007fff82bb2ea4 objc_addExceptionHandler + 302 2 com.apple.CoreFoundation 0x00007fff842b1090 _CFDoExceptionOperation + 528 3 com.apple.AppKit 0x00007fff81f75e26 _NSAppKitLock + 81 4 com.apple.AppKit 0x00007fff81f80f8f -[NSView nextKeyView] + 56 5 com.apple.AppKit 0x00007fff81f81018 -[NSView _primitiveSetNextKeyView:] + 72 6 com.apple.AppKit 0x00007fff820732b1 -[NSView _recursiveSetDefaultKeyViewLoop] + 242 7 com.apple.AppKit 0x00007fff82073300 -[NSView _recursiveSetDefaultKeyViewLoop] + 321 8 com.apple.AppKit 0x00007fff82073300 -[NSView _recursiveSetDefaultKeyViewLoop] + 321 9 com.apple.AppKit 0x00007fff82073300 -[NSView _recursiveSetDefaultKeyViewLoop] + 321 10 com.apple.AppKit 0x00007fff82073300 -[NSView _recursiveSetDefaultKeyViewLoop] + 321 11 com.apple.AppKit 0x00007fff82072fc3 -[NSView _setDefaultKeyViewLoop] + 279 12 com.apple.AppKit 0x00007fff82072e70 -[NSWindow recalculateKeyViewLoop] + 36 13 com.apple.AppKit 0x00007fff821dd149 -[NSSavePanel(NSSavePanelRuntime) _loadPreviousModeAndLayout] + 39 14 com.apple.AppKit 0x00007fff821dcf9e -[NSSavePanel(NSSavePanelRuntime) runModalForDirectory:file:types:] + 71 15 com.NZBVortex.NZBVortex 0x000000010000b7ee -[MainWindowViewController openNZBFileButtonClick:] + 62 16 com.apple.AppKit 0x00007fff821c96bf -[NSToolbarButton sendAction:to:] + 77 17 com.apple.AppKit 0x00007fff821c8bb7 -[NSToolbarItemViewer mouseDown:] + 5362 18 com.apple.AppKit 0x00007fff82082783 -[NSWindow sendEvent:] + 5068 19 com.apple.AppKit 0x00007fff8204fd46 -[NSApplication sendEvent:] + 5089 20 com.apple.AppKit 0x00007fff81faa562 -[NSApplication run] + 497 21 com.apple.AppKit 0x00007fff81f772f0 NSApplicationMain + 373 22 com.NZBVortex.NZBVortex 0x0000000100012a69 main + 9 23 com.NZBVortex.NZBVortex 0x0000000100001a84 start + 52

    Read the article

  • Insert random <script> for using $(document).ready(function()}); in Joomla

    - by Anriëtte Combrink
    Hi I have an article in which I use PHP code inside the text editor in Joomla, in the backend. I can see jQuery already called when the page loads, here is my code inside the Article edit textbox: <?php $username="XXX"; $password="XXX"; $database="XXX"; mysql_connect('localhost',$username,$password) or die(mysql_error()); mysql_select_db($database) or die("Unable to select database"); $result=mysql_query("SELECT * FROM birthdays ORDER BY name") or die(mysql_error()); echo "<table width='100%' cellspacing='10' cellpadding='0' border='0'>"; echo "<tr valign='top'><th align='left'></th><th align='left'>Name</th><th align='left'>Email</th><th align='left'>Day</th><th align='left'>Month</th></tr><tr><td>&nbsp;</td></tr>"; while ($row = mysql_fetch_array($result)) { echo "<tr>"; echo '<td valign="top"><a href="#" id="'.$row['id'].'" class="delete_birthday"><img src="administrator/components/com_media/images/remove.png" alt="Delete user" /></a><input type="hidden" name="id[]" value="'.$row['id'].'" /></td>'; echo "<td valign='top' style='border-bottom:1px dotted #333333; padding:2px;'>"; echo $row['name']; echo "</td>"; echo "<td valign='top' style='border-bottom:1px dotted #333333; padding:2px;'>"; echo $row['email']; echo "</td>"; echo "<td align='center' valign='top' style='border-bottom:1px dotted #333333; padding:2px;'>"; echo $row['birthday']; echo "</td>"; echo "<td align='center' valign='top' style='border-bottom:1px dotted #333333; padding:2px;'>"; echo $row['birthmonth']; echo "</td>"; echo "</tr>"; } echo "</table>"; ?> <script type="text/javascript"> $(document).ready(function() { alert("hello"); }); </script> At the moment, nothing alerts (just alerting for testing if jQuery gets recognised, I am obviously going to put in click handlers), so I assume the $(document).ready() never gets triggered. I can see the code in the source, but it just never gets called. Anybody have any advice? BTW. the SC jQuery plugin is installed already to prevent library conflicts.

    Read the article

  • Enabling XML-documentation for code contracts

    - by DigiMortal
    One nice feature that code contracts offer is updating of code documentation. If you are using source code documenting features of Visual Studio then code contracts may automate some tasks you otherwise have to implement manually. In this posting I will show you some XML documentation files with documented contracts. I will also explain how this feature works. Enabling XML-documentation in project settings As a first thing let’s enable generating of code documentation under project settings. Open project properties, move to Build page and make check to checkbox called “XML documentation file”. Save project settings and rebuild project. When project is built go to bin/Debug folder and open the XML-file. Here is my XML. <?xml version="1.0"?> <doc>     <assembly>         <name>Eneta.Examples.CodeContracts.Testable</name>     </assembly>     <members>         <member name="T:Eneta.Examples.CodeContracts.Testable.Randomizer">             <summary>             Class for generating random integers in user specified range.             </summary>         </member>         <member name="M:Eneta.Examples.CodeContracts.Testable.Randomizer.#ctor(Eneta.Examples.CodeContracts.Testable.IRandomGenerator)">             <summary>             Constructor of Randomizer. Initializes Randomizer class.             </summary>             <param name="generator">Instance of random number generator.</param>         </member>         <member name="M:Eneta.Examples.CodeContracts.Testable.Randomizer.GetRandomFromRangeContracted(System.Int32,System.Int32)">             <summary>             Returns random integer in given range.             </summary>             <param name="min">Minimum value of random integer.</param>             <param name="max">Maximum value of random integer.</param>         </member>     </members> </doc> You can see nothing about code contracts here. Enabling code contracts documentation Code contracts have their own settings and conditions for documentation. Open project properties and move to Code Contracts tab. From “Contract Reference Assembly” dropdown check Build and make check to checkbox “Emit contracts into XML doc file”. And again – save project setting, build the project and move to bin/Debug folder. Now you can see that there are two files for XML-documentation: <assembly name>.XML <assembly name>.old.XML First files is documentation with contracts, second file is original documentation without contracts. Let’s see now what is inside our new XML-documentation file. <?xml version="1.0"?> <doc>   <assembly>     <name>Eneta.Examples.CodeContracts.Testable</name>   </assembly>   <members>     <member name="T:Eneta.Examples.CodeContracts.Testable.Randomizer">       <summary>             Class for generating random integers in user specified range.             </summary>     </member>     <member name="M:Eneta.Examples.CodeContracts.Testable.Randomizer.#ctor(Eneta.Examples.CodeContracts.Testable.IRandomGenerator)">       <summary>             Constructor of Randomizer. Initializes Randomizer class.             </summary>       <param name="generator">Instance of random number generator.</param>     </member>     <member name="M:Eneta.Examples.CodeContracts.Testable.Randomizer.GetRandomFromRangeContracted(System.Int32,System.Int32)">       <summary>             Returns random integer in given range.             </summary>       <param name="min">Minimum value of random integer.</param>       <param name="max">Maximum value of random integer.</param>       <requires description="Min must be less than max" exception="T:System.ArgumentOutOfRangeException">                 min &lt; max</requires>       <exception cref="T:System.ArgumentOutOfRangeException">                 min &gt;= max</exception>       <ensures description="Return value is out of range">                 Contract.Result&lt;int&gt;() &gt;= min &amp;&amp;                 Contract.Result&lt;int&gt;() &lt;= max</ensures>     </member>   </members> </doc> As you can see then code contracts are pretty well documented. Messages that I provided with code contracts are also available in documentation. If I wrote very good and informative messages then these messages are very useful also in contracts documentation. Code contracts and Sandcastle Sandcastle knows nothing about code contracts by default. There is separate package of file for Sandcastle that is provided you by code contracts installation. You can read from code contracts manual: “Sandcastle (http://www.codeplex.com/Sandcastle) is a freely available tool that generates help les and web sites describing your APIs, based on the XML doc comments in your source code. The CodeContracts install contains a set of les that can be copied over a Sandcastle installation to take advantage of the additional contract information. The produced documentation adds a contract section to methods with declared requires and/or ensures. In order for Sandcastle to produce Contract sections, you need to patch a number of files in its installation. Please refer to the Sandcastle Readme.txt found under Start Menu/CodeContracts/Sandcastle for instructions. A future release of Sandcastle will hopefully support contract sections without the need for this patching step.” Integrating code contracts documentation to Sandcastle will be one of my next postings about code contracts. Conclusion if you are using code documentation then documentation about code contracts can be added to documentation very easily. All you have to do is to enable XML-documentation for contracts and build your project. Later you can use Sandcastle files provided by code contracts installer to integrate contracts documentation to your output documentation package.

    Read the article

  • Error in python - don't understand

    - by Jasper
    Hi, I'm creating a game, and am quite new to Python generally. I created a function 'descriptionGenerator()' which generates a description for characters and objects either randomly or using variables passed to it. It seemed to be working, but every now and then it wouldn't work correctly. So i placed it in a loop, and it never seems to be able to complete the loop without one of the iterations having this problem. The code is as follows: #+------------------------------------------+ #| Name: bitsandpieces.py | #| A module for the 'Europa I' game | #| created for the Game Making Competition | #| | #| Date Created/Modified: | #| 3/4/10 | 3/4/10 | #+------------------------------------------+ # Import the required modules # Import system modules: import time import random # Import 3rd party modules: # Import game modules: # Define the 'descriptionGenerator()' function def descriptionGenerator(descriptionVariables): descriptionVariableSize = len(descriptionVariables) if descriptionVariables[0] == 'char': # If there is only one variable ('char'), create a random description if descriptionVariableSize == 1: # Define choices for descriptionVariables to be generated from gender_choices = ['male', 'female'] hair_choices = ['black', 'red', 'blonde', 'grey', 'brown', 'blue'] hair_choices2 = ['long', 'short', 'cropped', 'curly'] size_choices = ['tubby', 'thin', 'fat', 'almost twig-like'] demeanour_choices = ['glowering', 'bright', 'smiling', 'sombre', 'intelligent'] impression_choices = ['likeable', 'unlikeable', 'dangerous', 'annoying', 'afraid'] # Define description variables gender = random.choice(gender_choices) height = str(float('0.' + str(random.randint(1, 9))) + float(random.randint(1, 2))) if float(height) > 1.8: height_string = 'tall' if float(height) > 2: height_string = 'very tall' elif float(height) < 1.8 and float(height) > 1.5: height_string = 'average' elif float(height) < 1.5: height_string = 'short' if float(height) < 1.3: height_string = 'very short' hair = random.choice(hair_choices2) + ' ' + random.choice(hair_choices) size = random.choice(size_choices) demeanour = random.choice(demeanour_choices) impression = random.choice(impression_choices) # Collect description variables in list 'randomDescriptionVariables' randomDescriptionVariables = ['char', gender, height, height_string, hair, size, demeanour, impression] # Generate description using the 'descriptionGenerator' function descriptionGenerator(randomDescriptionVariables) # Generate the description of a character using the variables passed to the function elif descriptionVariableSize == 8: if descriptionVariables[1] == 'male': if descriptionVariables[7] != 'afraid': print """A %s man, about %s m tall. He has %s hair and is %s. He is %s and you get the impression that he is %s.""" %(descriptionVariables[3], descriptionVariables[2], descriptionVariables[4], descriptionVariables[5], descriptionVariables[6], descriptionVariables[7]) elif descriptionVariables[7] == 'afraid': print """A %s man, about %s m tall. He has %s hair and is %s. He is %s.\nYou feel that you should be %s of him.""" %(descriptionVariables[3], descriptionVariables[2], descriptionVariables[4], descriptionVariables[5], descriptionVariables[6], descriptionVariables[7]) elif descriptionVariables[1] == 'female': if descriptionVariables[7] != 'afraid': print """A %s woman, about %s m tall. She has %s hair and is %s. She is %s and you get the impression that she is %s.""" %(descriptionVariables[3], descriptionVariables[2], descriptionVariables[4], descriptionVariables[5], descriptionVariables[6], descriptionVariables[7]) elif descriptionVariables[7] == 'afraid': print """A %s woman, about %s m tall. She has %s hair and is %s. She is %s.\nYou feel that you should be %s of her.""" %(descriptionVariables[3], descriptionVariables[2], descriptionVariables[4], descriptionVariables[5], descriptionVariables[6], descriptionVariables[7]) else: pass elif descriptionVariables[0] == 'obj': # Insert code here 2 deal with object stuff pass print print myDescriptionVariables = ['char'] i = 0 while i < 30: print print print descriptionGenerator(myDescriptionVariables) i = i + 1 time.sleep(10) When it fails to properly execute it says this: Traceback (most recent call last): File "/Users/Jasper/Development/Programming/MyProjects/Game Making Challenge/Europa I/Code/Code 2.0/bitsandpieces.py", line 79, in <module> descriptionGenerator(myDescriptionVariables) File "/Users/Jasper/Development/Programming/MyProjects/Game Making Challenge/Europa I/Code/Code 2.0/bitsandpieces.py", line 50, in descriptionGenerator randomDescriptionVariables = ['char', gender, height, height_string, hair, size, demeanour, impression] UnboundLocalError: local variable 'height_string' referenced before assignment Thanks for any help with this

    Read the article

  • Problem creating checklist (similar to TouchCells sample code) app for iPhone. Random cells get chec

    - by Jonah
    I've been having a problem creating a checklist in the style of the TouchCells example from the Apple sample code. Basically, it is a table that allows multiple selection of its items and gives each selected item a check mark. The problem I'm having is that when I select an item and then scroll down the screen, another item (off the screen) will randomly be selected. It seems that it is usually the next cell to be loaded on the screen. I couldn't figure out what I was doing wrong so I tested it with Apple's TouchCells code. In their program though, they only have 6 cells and there is no room to scroll. So, I duplicated some of the items from the plist file to make more cells and... the same problem pops up. If you select a cell and then scroll, another cell will randomly be selected. Update I recently tried the iPhone Dev Cookbook sample code named "Checks" and... you guessed it, the same problem. Here's the link: http://code.google.com/p/cookbooksamples/downloads/list This is driving me nuts. Is it a bug or am I doing something wrong? Does anyone know how to fix this? Thanks! Also, does anyone know of any sample code that shows how to do this?

    Read the article

  • Select a random row from table, but with odds?

    - by Don
    I have a table that describes a variety of objects in my system (ie. umbrella, boots, satchel, whatever). Each one of these objects needs to have a distinct prevalence or incidence. For example, the umbrella is rarer than the boots. Based on those factors, I need to randomly select a single object (including a blank or 'no object found') based on that incidence value. Yikes. Make sense?

    Read the article

  • More Efficient Data Structure for Large Layered Tile Map

    - by Stupac
    It seems like the popular method is to break the map up into regions and load them as needed, my problem is that in my game there are many AI entities other than the player out performing actions in virtually all the regions of the map. Let's just say I have a 5000x5000 map, when I use a 2D array of byte's to render it my game uses around 17 MB of memory, as soon as I change that data structure to a my own defined MapCell class (which only contains a single field: byte terrain) my game's memory consumption rockets up to 400+ MB. I plan on adding layering, so an array of byte's won't cut it and I figure I'd need to add a List of some sort to the MapCell class to provide objects in the layers. I'm only rendering tiles that are on screen, but I need the rest of the map to be represented in memory since it is constantly used in Update. So my question is, how can I reduce the memory consumption of my map while still maintaining the above requirements? Thank you for your time! Here's a few snippets my C# code in XNA4: public static void LoadMapData() { // Test map generations int xSize = 5000; int ySize = 5000; MapCell[,] map = new MapCell[xSize,ySize]; //byte[,] map = new byte[xSize, ySize]; Terrain[] terrains = new Terrain[4]; terrains[0] = grass; terrains[1] = dirt; terrains[2] = rock; terrains[3] = water; Random random = new Random(); for(int x = 0; x < xSize; x++) { for(int y = 0; y < ySize; y++) { //map[x,y] = new MapCell(terrains[random.Next(4)]); map[x,y] = new MapCell((byte)random.Next(4)); //map[x, y] = (byte)random.Next(4); } } testMap = new TileMap(map, xSize, ySize); // End test map setup currentMap = testMap; } public class MapCell { //public TerrainType terrain; public byte terrain; public MapCell(byte itsTerrain) { terrain = itsTerrain; } // the type of terrain this cell is treated as /*public Terrain terrain { get; set; } public MapCell(Terrain itsTerrain) { terrain = itsTerrain; }*/ }

    Read the article

  • Why am I getting such random results when checking DNS?

    - by animuson
    The code is as follows: $domain = "fosajfjdkgdajfhsd.com"; $check1 = checkdnsrr($domain, "MX"); $check2 = checkdnsrr($domain, "A"); $check3 = (checkdnsrr($domain, "MX") || checkdnsrr($domain, "A")); $check4 = !(checkdnsrr($domain, "MX") || checkdnsrr($domain, "A")); die("{$check1} - {$check2} - {$check3} - {$check4}"); However when I check the output to see what it's returning, I get this: - 1 - 1 - The domain obviously wouldn't exist, so I don't understand why checking the A record is return true and checking the MX result doesn't give me anything at all. I don't understand what's going wrong here.

    Read the article

  • Is it safe to use random Unicode for complex delimiter sequences in strings?

    - by ccomet
    Question: In terms of program stability and ensuring that the system will actually operate, how safe is it to use chars like ¦, § or ‡ for complex delimiter sequences in strings? Can I reliable believe that I won't run into any issues in a program reading these incorrectly? I am working in a system, using C# code, in which I have to store a fairly complex set of information within a single string. The readability of this string is only necessary on the computer side, end-users should only ever see the information after it has been parsed by the appropriate methods. Because some of the data in these strings will be collections of variable size, I use different delimiters to identify what parts of the string correspond to a certain tier of organization. There are enough cases that the standard sets of ;, |, and similar ilk have been exhausted. I considered two-char delimiters, like ;# or ;|, but I felt that it would be very inefficient. There probably isn't that large of a performance difference in storing with one char versus two chars, but when I have the option of picking the smaller option, it just feels wrong to pick the larger one. So finally, I considered using the set of characters like the double dagger and section. They only take up one char, and they are definitely not going to show up in the actual text that I'll be storing, so they won't be confused for anything. But character encoding is finicky. While the visibility to the end user is meaningless (since they, in fact, won't see it), I became recently concerned about how the programs in the system will read it. The string is stored in one database, while a separate program is responsible for both encoding and decoding the string into different object types for the rest of the application to work with. And if something is expected to be written one way, is possibly written another, then maybe the whole system will fail and I can't really let that happen. So is it safe to use these kind of chars for background delimiters?

    Read the article

< Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >