Search Results

Search found 522 results on 21 pages for 'sean mcmillan'.

Page 11/21 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • How do you solve the 15-puzzle with A-Star or Dijkstra's Algorithm?

    - by Sean
    I've read in one of my AI books that popular algorithms (A-Star, Dijkstra) for path-finding in simulation or games is also used to solve the well-known "15-puzzle". Can anyone give me some pointers on how I would reduce the 15-puzzle to a graph of nodes and edges so that I could apply one of these algorithms? If I were to treat each node in the graph as a game state then wouldn't that tree become quite large? Or is that just the way to do it?

    Read the article

  • git pull currently tracked branch

    - by Sean Clark Hess
    I use git checkout -b somebranch origin/somebranch to make sure my local branches track remotes already. I would like a way to pull from the tracked branch no matter which branch I am using. In other words, I want to say git pull or some other command, without specifying the branch, and have it mean git pull origin somebranch if I'm on the local branch somebranch Is there a way to do this without putting an entry in the config file for each branch? It would be difficult to maintain if we have to remember to manually enter some config stuff for each branch.

    Read the article

  • Android: Crashed when single contact is clicked

    - by Sean Tan
    My application is always crashed at this moment, guru here please help me to solved. Thanks.The situation now is as mentioned in title above. Hereby is my AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2009 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.android.contactmanager" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="10" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/> <uses-permission android:name="android.permission.WRITE_OWNER_DATA"/> <uses-permission android:name="android.permission.CAMERA"/> <uses-permission android:name="android.permission.CALL_PHONE"/> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_CONTACTS" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.CAMERA"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.GET_ACCOUNTS"/> <application android:label="@string/app_name" android:icon="@drawable/icon" android:allowBackup="true"> <!-- --><activity android:name=".ContactManager" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="ContactAdder" android:label="@string/addContactTitle"> </activity> <activity android:name=".SingleListContact" android:label="Contact Person Details"> </activity> </application> </manifest> The SingleListContact.java package com.example.android.contactmanager; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.widget.TextView; public class SingleListContact extends Activity{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.single_list_contact_view); TextView txtContact = (TextView) findViewById(R.id.contactList); Intent i = getIntent(); // getting attached intent data String contact = i.getStringExtra("contact"); // displaying selected product name txtContact.setText(contact); } } My ContactManager.java as below /* * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.example.android.contactmanager; import android.app.Activity; import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.ContactsContract; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.ListView; import android.widget.SimpleCursorAdapter; import android.widget.TextView; public final class ContactManager extends Activity implements OnItemClickListener { public static final String TAG = "ContactManager"; private Button mAddAccountButton; private ListView mContactList; private boolean mShowInvisible; //public BooleanObservable ShowInvisible = new BooleanObservable(false); private CheckBox mShowInvisibleControl; /** * Called when the activity is first created. Responsible for initializing the UI. */ @Override public void onCreate(Bundle savedInstanceState) { Log.v(TAG, "Activity State: onCreate()"); super.onCreate(savedInstanceState); setContentView(R.layout.contact_manager); // Obtain handles to UI objects mAddAccountButton = (Button) findViewById(R.id.addContactButton); mContactList = (ListView) findViewById(R.id.contactList); mShowInvisibleControl = (CheckBox) findViewById(R.id.showInvisible); // Initialise class properties mShowInvisible = false; mShowInvisibleControl.setChecked(mShowInvisible); // Register handler for UI elements mAddAccountButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Log.d(TAG, "mAddAccountButton clicked"); launchContactAdder(); } }); mShowInvisibleControl.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Log.d(TAG, "mShowInvisibleControl changed: " + isChecked); mShowInvisible = isChecked; populateContactList(); } }); mContactList = (ListView) findViewById(R.id.contactList); mContactList.setOnItemClickListener(this); // Populate the contact list populateContactList(); } /** * Populate the contact list based on account currently selected in the account spinner. */ private void populateContactList() { // Build adapter with contact entries Cursor cursor = getContacts(); String[] fields = new String[] { ContactsContract.Data.DISPLAY_NAME }; SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.contact_entry, cursor, fields, new int[] {R.id.contactEntryText}); mContactList.setAdapter(adapter); } /** * Obtains the contact list for the currently selected account. * * @return A cursor for for accessing the contact list. */ private Cursor getContacts() { // Run query Uri uri = ContactsContract.Contacts.CONTENT_URI; String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '" + (mShowInvisible ? "0" : "1") + "'"; //String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '" + (mShowInvisible.get() ? "0" : "1") + "'"; String[] selectionArgs = null; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return this.managedQuery(uri, projection, selection, selectionArgs, sortOrder); } /** * Launches the ContactAdder activity to add a new contact to the selected account. */ protected void launchContactAdder() { Intent i = new Intent(this, ContactAdder.class); startActivity(i); } public void onItemClick(AdapterView<?> l, View v, int position, long id) { Log.i("TAG", "You clicked item " + id + " at position " + position); // Here you start the intent to show the contact details // selected item TextView tv=(TextView)v.findViewById(R.id.contactList); String allcontactlist = tv.getText().toString(); // Launching new Activity on selecting single List Item Intent i = new Intent(getApplicationContext(), SingleListContact.class); // sending data to new activity i.putExtra("Contact Person", allcontactlist); startActivity(i); } } contact_entry.xml <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2009 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <ListView android:layout_width="wrap_content" android:id="@+id/contactList" android:layout_height="0dp" android:padding="10dp" android:textSize="200sp" android:layout_weight="10"/> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/showInvisible" android:text="@string/showInvisible"/> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/addContactButton" android:text="@string/addContactButtonLabel"/> </LinearLayout> Logcat result: 12-05 05:00:31.289: E/AndroidRuntime(642): FATAL EXCEPTION: main 12-05 05:00:31.289: E/AndroidRuntime(642): java.lang.NullPointerException 12-05 05:00:31.289: E/AndroidRuntime(642): at com.example.android.contactmanager.ContactManager.onItemClick(ContactManager.java:148) 12-05 05:00:31.289: E/AndroidRuntime(642): at android.widget.AdapterView.performItemClick(AdapterView.java:284) 12-05 05:00:31.289: E/AndroidRuntime(642): at android.widget.ListView.performItemClick(ListView.java:3513) 12-05 05:00:31.289: E/AndroidRuntime(642): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812) 12-05 05:00:31.289: E/AndroidRuntime(642): at android.os.Handler.handleCallback(Handler.java:587) 12-05 05:00:31.289: E/AndroidRuntime(642): at android.os.Handler.dispatchMessage(Handler.java:92) 12-05 05:00:31.289: E/AndroidRuntime(642): at android.os.Looper.loop(Looper.java:123) 12-05 05:00:31.289: E/AndroidRuntime(642): at android.app.ActivityThread.main(ActivityThread.java:3683) 12-05 05:00:31.289: E/AndroidRuntime(642): at java.lang.reflect.Method.invokeNative(Native Method) 12-05 05:00:31.289: E/AndroidRuntime(642): at java.lang.reflect.Method.invoke(Method.java:507) 12-05 05:00:31.289: E/AndroidRuntime(642): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 12-05 05:00:31.289: E/AndroidRuntime(642): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 12-05 05:00:31.289: E/AndroidRuntime(642): at dalvik.system.NativeStart.main(Native Method)

    Read the article

  • PHP Key name array

    - by Sean McRaghty
    I have an array $data fruit => apple, seat => sofa, etc. I want to loop through so that each key becomes type_key[0]['value'] so eg type_fruit[0]['value'] => apple, type_seat[0]['value'] => sofa, and what I thought would do this, namely foreach ($data as $key => $value) { # Create a new, renamed, key. $array[str_replace("/(.+)/", "type_$1[0]['value']", $key)] = $value; # Destroy the old key/value pair unset($array[$key]); } print_r($array); Doesn't work. How can I make it work? Also, I want everything to be in the keys (not the values) to be lowercase: is there an easy way of doing this too? Thanks.

    Read the article

  • managed beans as managed properties

    - by Sean
    I am using JSF 1.1 on WebSphere 6.1. I am building search functionality within an application and am having some issues. I've stripped out the extras, and have left myself with the following: 4 managed beans: SearchController - Controller bean, session scope SearchResults - session scope (store the results) ProductSearch - session scope (store the search conditions) ResultsBacking - Backing bean for DataTable, used to determine which row was clicked, request scope The SearchController bean has, as managed properties, the other 3. All except ResultsBacking are session scoped. If there is only 1 item in the search results, I want to bring up that record directly. I call setFirst(0) for the data table in the ResultsBacking method (I want to use the existing method that handle which item was clicked, so this is called right after the setFirst). When I go to do another search, I get an IllegalArgumentException when calling getRowData in the data table. According to the api, this is thrown 'if now(sic) row data is available at the currently specified row index'. I'm confused as to why this happens. It works the first time but not the second. Do I need to remove the ResultsBacking on a new search to get rid of the old state?

    Read the article

  • Using ZeroC Middleware

    - by Sean
    I'm currently looking at various middleware solutions that will allow me to create applications in a variety of languages which are able to communicate amongst each other. The ZeroC product suite seems ideal as it provides a language agnostic way of defining data and the services that operate on the data (via its ICE idl) and provides support for all the mainstream languages. It also appears to offer a lot of other things we'd want, such as load balancing, grid computing and managed deployment. However, my google-fu has let me down and I'm having trouble finding information from people who have used it to implements system. I'm looking for feedback from projects that use it, and what issues/successes they had. I'm also interested in feedback from projects that evaluated it and chose not to use it (and why).

    Read the article

  • MySQL index cardinality - performance vs storage efficiency

    - by Sean
    Say you have a MySQL 5.0 MyISAM table with 100 million rows, with one index (other than primary key) on two integer columns. From my admittedly poor understanding of B-tree structure, I believe that a lower cardinality means the storage efficiency of the index is better, because there are less parent nodes. Whereas a higher cardinality means less efficient storage, but faster read performance, because it has to navigate through less branches to get to whatever data it is looking for to narrow down the rows for the query. (Note - by "low" vs "high", I don't mean e.g. 1 million vs 99 million for a 100 million row table. I mean more like 90 million vs 95 million) Is my understanding correct? Related question - How does cardinality affect write performance?

    Read the article

  • NSBorderlessWindow not responding to CMD-W/CMD-M

    - by Sean
    I have an NSBorderlessWindow subclass of NSWindow with a transparent and non-opaque background (so it's non-rectangular in appearance). I've added my own buttons to function as the close and minimize buttons when I click them, but for some reason the window will not respond to CMD-W or CMD-M like a normal one does. I have my NSWindow subclass set to return YES to canBecomeKeyWindow and canBecomeMainWindow. My NIB still has all the standard menu items in it that are there when you create a new project - including the "Minimize" item in the Window menu with the default shortcut CMD-M defined. It's hooked up to send performMiniaturize: to the first responder. However it is not enabled when the app is run, so it seems like it must be asking the window if it can minimize and the window says no or something. (I'm still very new to OSX/Cocoa.) What am I missing? Also, and maybe this is related, my borderless window has a shadow enabled - but unlike a normal titled window, when I make my window the active/front window by clicking on it, the shadow doesn't change. Normally an OSX focused window has a slightly larger/darker shadow to make it stand out more but mine never changes the shadow. It's like I'm missing something to make the OS treat this window as a real/normal/main window or something and as a result I lose the shadow change and functioning CMD-W/CMD-M.

    Read the article

  • Get the date of a given day in a given week...

    - by Sean.C
    i need to start at a year-month and work out what the date it is in a given week, on a given day within that week.. i.e year: 2009 month: 10 week: 5 day-number: 0 would return 2009-10-25 00:00:00 which is a sunday. Notice week 5, there is no day 0 in week 5 in 2009-10 as the sunday in that logical week is 2009-11-01 00:00:00... so week 5 would always return the last possible date for the given day in the given month.. if you havn't guessed already i'm messing with the c struct TIME_ZONE_INFORMATION (link text) which is pretty crazy if i'm fair... Date math and SQL are something to be admired, sadly its something i have never really dug deep into beyond stripping times. Any help would be greatly appriciated. PS: mssql 2005 btw..

    Read the article

  • I'm using a sequence in Factory Girl to get unique values but I'm getting validation errors

    - by Sean Seefried
    I have a model defined this way class Lga < ActiveRecord::Base validates_uniqueness_of :code validates_presence_of :name end I've defined a factory for Lgas with Factory.sequence(:lga_id) { |n| n + 10000 } Factory.define :lga do |l| id = Factory.next :lga_id l.code "lga_#{id}" l.name "LGA #{id}" end However, when I run Factory.create(:lga) Factory.create(:lga) in script/console I get >> Factory.create(:lga) => #<Lga id: 2, code: "lga_10001", name: "LGA 10001", created_at: "2010-03-18 23:55:29", updated_at: "2010-03-18 23:55:29"> >> Factory.create(:lga) ActiveRecord::RecordInvalid: Validation failed: Code has already been taken

    Read the article

  • Application Context in Rails

    - by Sean McMains
    Rails comes with a handy session hash into which we can cram stuff to our heart's content. I would, however, like something like ASP's application context, which instead of sharing data only within a single session, will share it with all sessions in the same application. I'm writing a simple dashboard app, and would like to pull data every 5 minutes, rather than every 5 minutes for each session. I could, of course, store the cache update times in a database, but so far haven't needed to set up a database for this app, and would love to avoid that dependency if possible. So, is there any way to get (or simulate) this sort of thing? If there's no way to do it without a database, is there any kind of "fake" database engine that comes with Rails, runs in memory, but doesn't bother persisting data between restarts?

    Read the article

  • Emulating a web browser

    - by Sean
    Hello, we are tasked with basically emulating a browser to fetch webpages, looking to automate tests on different web pages. This will be used for (ideally) console-ish applications that run in the background and generate reports. We tried going with .NET and the WatiN library, but it was built on a Marshalled IE, and so it lacked many features that we hacked in with calls to unmanaged native code, but at the end of the day IE is not thread safe nor process safe, and many of the needed features could only be implemented by changing registry values and it was just terribly unflexible. Proxy support JavaScript support- we have to be able to parse the actual DOM after any javascript has executed (and hopefully an event is raised to handle any ajax calls) Ability to save entire contents of page including images FROM THE loaded page's CACHE to a separate location ability to clear cookies/cache, get the cookies/cache, etc. Ability to set headers and alter post data for any browser call And for the love of drogs, an API that isn't completely cryptic Languages acceptable C++, C#, Python, anything that can be a simple little console application that doesn't have a retarded syntax like Ruby. From my own research, and believe me I am terrible at google searches, I have heard good things about WebKit... would the Qt module QtWebKit handle all these features?

    Read the article

  • mysql - select pagination chunk that includes a given id

    - by sean smith
    ...before the pagination chunks have been determined. I know you can do this in multiple statements, but there must be a better way. my results are returned ordered by date and I want to return the pagination chunk that contains a given id. So I could, for example, select the date of the given id and then select a chunk of results where date is less than or greater than the date. That would work. But is there some native mysql method of doing this sort of thing in one statement? It just seems reasonable to expect that we could ask for X results in which a given id exists if results are ordered by date.

    Read the article

  • Using perl to parse a file and insert specific values into a database

    - by Sean
    Disclaimer: I'm a newbie at scripting in perl, this is partially a learning exercise (but still a project for work). Also, I have a much stronger grasp on shell scripting, so my examples will likely be formatted in that mindset (but I would like to create them in perl). Sorry in advance for my verbosity, I want to make sure I am at least marginally clear in getting my point across I have a text file (a reference guide) that is a Word document converted to text then swapped from Windows to UNIX format in Notepad++. The file is uniform in that each section of the file had the same fields/formatting/tables. What I have planned to do, in a basic way is grab each section, keyed by unique batch job names and place all of the values into a database (or maybe just an excel file) so all the fields can be searched/edited for each job much easier than in the word file and possibly create a web interface later on. So what I want to do is grab each section by doing something like: sed -n '/job_name_1_regex/,/job_name_2_regex/' file.txt --how would this be formatted within a perl script? (grab the section in total, then break it down further from there) To read the file in the script I have open FORMAT_FILE, 'test_format.txt'; and then use foreach $line (<FORMAT_FILE>) to parse the file line by line. --is there a better way? My next problem is that since I converted from a word doc with tables, which looks like: Table Heading 1 Table Heading 2 Heading 1/Value 1 Heading 2/Value 1 Heading 1/Value 2 Heading 2/Value 2 but the text file it looks like: Table Heading 1 Table Heading 2Heading 1/Value 1Heading 1/Value 2Heading 2/Value 1Heading 2/Value 2 So I want to have "Heading 1" and "Heading 2" as a columns name and then put the respective values there. I just am not sure how to get the values in relation to the heading from the text file. The values of Heading 1 will always be the line number of Heading 1 plus 2 (Heading 1, Heading 2, Values for heading 1). I know this can be done in awk/sed pretty easily, just not sure how to address it inside a perl script. After I have all the right values and such, linking it up to a database may be an issue as well, I haven't started looking at the way perl interacts with DBs yet. Sorry if this is a bit scatterbrained...it's still not fully formed in my head.

    Read the article

  • How to use bundler gem binaries in path

    - by Sean Chambers
    I just started using bundler for gem packaging in vendor/. The problem is with certain gems (like rspec and cucumber) that have binaries. The binary path that is under my_app/vendor/gems/ruby/1.8/...cucumber-0.6.2/bin/ is not in my path, therefore when I go to run cucumber i get command cannot be found. What is the easiest way to execute the bundled gem binaries from within the app rather than adding a large number of folders to my path? Thanks

    Read the article

  • VB.Net how to wait for a different form to close before continuing on.

    - by Sean P
    I have a little log in screen that pops up if a user selects a certain item on my main form. How do I get my code to stop executing til my log in form closes? This is what I am doing so far. Basically i want o execute the code after MyLogin closes. BMSSplash.MyLogin.Show() If isLoggedIn Then BMSSplash.MyBuddy.Show() Cursor.Current = Cursors.WaitCursor End If

    Read the article

  • How to avoid code duplication for one-off methods with a slightly different signature

    - by Sean
    I am wrapping a number of functions from a vender API in C#. Each of the wrapping functions will fit the pattern: public IEnumerator<IValues> GetAggregateValues(string pointID, DateTime startDate, DateTime endDate, TimeSpan period) { // Validate Data // Break up Requesting Time-Span // Make Requests // Read Results (through another method call } 5 of the 6 requests are aggregate data pulls and have the same signature, so it makes sense to put them in one method and pass the aggregate type to avoid duplication of code. The 6th method however follows the exact same pattern with the same result-set, but is not an aggregate, so no time period is passed to the function (changing the signature). Is there an elegant way to handle this kind of situation without coding a one-off function to handle the non-aggregate request?

    Read the article

  • Is It Possible To Use Javascript/CSS To Swap Style Sheets When A Mobile Device Rotates?

    - by Sean M
    I am working on a site that must be designed with mobile accessibility in mind. As part of our brainstorming, we wondered whether it's possible to detect, for a mobile browser (i.e. Mobile Safari or the Android browser), when the viewing device has changed orientation, and to use that as a trigger to change page content? As the title of this question implies, our best-case scenario is the ability to detect the orientation change and use it to alter the CSS on the fly so as to present a slightly different page for landscape versus portrait. Of course we can just design for a page that looks good one way and make it obvious that it's supposed to be viewed that way, but the cool-stuff factor of a page that looks good either way is pretty appealing. Is this idea implementable? Practical?

    Read the article

  • mysql index optimization for a table with multiple indexes that index some of the same columns

    - by Sean
    I have a table that stores some basic data about visitor sessions on third party web sites. This is its structure: id, site_id, unixtime, unixtime_last, ip_address, uid There are four indexes: id, site_id/unixtime, site_id/ip_address, and site_id/uid There are many different types of ways that we query this table, and all of them are specific to the site_id. The index with unixtime is used to display the list of visitors for a given date or time range. The other two are used to find all visits from an IP address or a "uid" (a unique cookie value created for each visitor), as well as determining if this is a new visitor or a returning visitor. Obviously storing site_id inside 3 indexes is inefficient for both write speed and storage, but I see no way around it, since I need to be able to quickly query this data for a given specific site_id. Any ideas on making this more efficient? I don't really understand B-trees besides some very basic stuff, but it's more efficient to have the left-most column of an index be the one with the least variance - correct? Because I considered having the site_id being the second column of the index for both ip_address and uid but I think that would make the index less efficient since the IP and UID are going to vary more than the site ID will, because we only have about 8000 unique sites per database server, but millions of unique visitors across all ~8000 sites on a daily basis. I've also considered removing site_id from the IP and UID indexes completely, since the chances of the same visitor going to multiple sites that share the same database server are quite small, but in cases where this does happen, I fear it could be quite slow to determine if this is a new visitor to this site_id or not. The query would be something like: select id from sessions where uid = 'value' and site_id = 123 limit 1 ... so if this visitor had visited this site before, it would only need to find one row with this site_id before it stopped. This wouldn't be super fast necessarily, but acceptably fast. But say we have a site that gets 500,000 visitors a day, and a particular visitor loves this site and goes there 10 times a day. Now they happen to hit another site on the same database server for the first time. The above query could take quite a long time to search through all of the potentially thousands of rows for this UID, scattered all over the disk, since it wouldn't be finding one for this site ID. Any insight on making this as efficient as possible would be appreciated :) Update - this is a MyISAM table with MySQL 5.0. My concerns are both with performance as well as storage space. This table is both read and write heavy. If I had to choose between performance and storage, my biggest concern is performance - but both are important. We use memcached heavily in all areas of our service, but that's not an excuse to not care about the database design. I want the database to be as efficient as possible.

    Read the article

  • Python - Test directory permissions

    - by Sean
    In Python on Windows, is there a way to determine if a user has permission to access a directory? I've taken a look at os.access but it gives false results. >>> os.access('C:\haveaccess', os.R_OK) False >>> os.access(r'C:\haveaccess', os.R_OK) True >>> os.access('C:\donthaveaccess', os.R_OK) False >>> os.access(r'C:\donthaveaccess', os.R_OK) True Am I doing something wrong? Is there a better way to check if a user has permission to access a directory?

    Read the article

  • Raise event from http listener (Async listener handler)

    - by Sean
    Hello, I have created an simple web server, leveraging .NET HttpListener class. I am using ThreadPool.QueueUserWorkItem() to spawn a thread to listen to incoming requests. Threaded method uses HttpListener.BeginGetContext(callback, listener), and in callback method I resume with HttpListener.EndGetContext() as well as raise an even to notify UI that listener received data. This is the question - how to raise that event? Initially I used ThreadPool: ThreadPool.QueueUserWorkItem(state => ReceivedRequest(httpListenerContext, receivedRequestArgs)); But then started to doubt, maybe it should be a dedicated thread (as appose to waiting for a thread from pool): new Thread(() => ReceivedRequest(httpListenerContext, receivedRequestArgs)).Start(); Thoughts? 10X

    Read the article

  • Linked List exercise, what am I doing wrong?

    - by Sean Ochoa
    Hey all. I'm doing a linked list exercise that involves dynamic memory allocation, pointers, classes, and exceptions. Would someone be willing to critique it and tell me what I did wrong and what I should have done better both with regards to style and to those subjects I listed above? /* Linked List exercise */ #include <iostream> #include <exception> #include <string> using namespace std; class node{ public: node * next; int * data; node(const int i){ data = new int; *data = i; } node& operator=(node n){ *data = *(n.data); } ~node(){ delete data; } }; class linkedList{ public: node * head; node * tail; int nodeCount; linkedList(){ head = NULL; tail = NULL; } ~linkedList(){ while (head){ node* t = head->next; delete head; if (t) head = t; } } void add(node * n){ if (!head) { head = n; head->next = NULL; tail = head; nodeCount = 0; }else { node * t = head; while (t->next) t = t->next; t->next = n; n->next = NULL; nodeCount++; } } node * operator[](const int &i){ if ((i >= 0) && (i < nodeCount)) throw new exception("ERROR: Invalid index on linked list.", -1); node *t = head; for (int x = i; x < nodeCount; x++) t = t->next; return t; } void print(){ if (!head) return; node * t = head; string collection; cout << "["; int c = 0; if (!t->next) cout << *(t->data); else while (t->next){ cout << *(t->data); c++; if (t->next) t = t->next; if (c < nodeCount) cout << ", "; } cout << "]" << endl; } }; int main (const int & argc, const char * argv[]){ try{ linkedList * myList = new linkedList; for (int x = 0; x < 10; x++) myList->add(new node(x)); myList->print(); }catch(exception &ex){ cout << ex.what() << endl; return -1; } return 0; }

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >