Daily Archives

Articles indexed Thursday May 13 2010

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

  • Random record from MongoDB

    - by Will M
    I am looking to get a random record from a huge (100 million record) mongodb. What is the fastest and most efficient way to do so? The data is already there and there are no field in which I can generate a random number and obtain a random row. Any suggestions?

    Read the article

  • PHP Filesystem Pagination

    - by Byron
    How does one paginate a large listing of files within a folder? I can't see any functions in the PHP documentation that mention any way to specify an 'offset'. Both glob() and scandir() simply return all the files in the folder, and I'm afraid that won't be a good idea for a huge directory. Is there any better way of doing this than simply going through all the files and chopping off the first X number of files?

    Read the article

  • SQL SERVER Four Posts on Removing the Bookmark Lookup Key Lookup

    In recent times I have observed that not many people have proper understanding of what is bookmark lookup or key lookup. Increasing numbers of the questions tells me that this is something developers are encountering every single day but have no idea how to deal with it. I have previously written three articles on this [...]...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • md5sum or sha1sum of legitmate microsoft system files

    - by martyvis
    Is there a database or repository of the legitimate checksums for Microsoft system files? We think we have a 0day on DNS for Windows 2003 SP2 using IRC for command and control. (Latest McAfee does not see an issue). I want to compare our customer's dns.exe and associated DLLs with the real ones. (I will grab a fresh SP2 and hotfixed system to do this, but wonder how to do this in future without needed to do this.)

    Read the article

  • Why won't my UISearchDisplayController fire the didSelectRowAtIndexPath moethod?

    - by John Wells
    I am having an odd problem when searching a UITableView using a UISearchDisplayController. The UITableViewController is a subclass of another UITableViewController with a working didSelectRowAtIndexPath method. Without searching the controller handles selections fine, sending the superclass a didSelectRowAtIndexPath call, but if I select a cell when searching the superclass receives nothing but the cell is highlighted. Below is the code from my subclass. @implementation AdvancedViewController @synthesize searchDisplayController, dict, filteredList; - (void)viewDidLoad { [super viewDidLoad]; // Programmatically set up search bar UISearchBar *mySearchBar = [[UISearchBar alloc] init]; mySearchBar.delegate = self; [mySearchBar setAutocapitalizationType:UITextAutocapitalizationTypeNone]; [mySearchBar sizeToFit]; self.tableView.tableHeaderView = mySearchBar; // Programmatically set up search display controller searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:mySearchBar contentsController:self]; [self setSearchDisplayController:searchDisplayController]; [searchDisplayController setDelegate:self]; [searchDisplayController setSearchResultsDataSource:self]; // Parse data from server NSData * jsonData = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]]; NSArray * items = [[NSArray alloc] initWithArray:[[CJSONDeserializer deserializer] deserializeAsArray:jsonData error:nil]]; // Init variables dict = [[NSMutableDictionary alloc] init]; listIndex = [[NSMutableArray alloc] init]; fullList = [[NSMutableArray alloc] init]; filteredList = [[NSMutableArray alloc] init]; // Get each item and format it for the UI for(NSMutableArray * item in items) { // Get the first letter NSString * firstKey = [[[item objectAtIndex:0] substringWithRange:NSMakeRange(0,1)] uppercaseString]; // Put symbols and numbers in the same section if ([[firstKey stringByTrimmingCharactersInSet:[[NSCharacterSet letterCharacterSet] invertedSet]] isEqualToString:@""]) firstKey = @"#"; // If there isn't a section with this key if (![listIndex containsObject:firstKey]) { // Add the key to the index for faster access (because it's already sorted) [listIndex addObject:firstKey]; // Add the key to the unordered dictionary [dict setObject:[NSMutableArray array] forKey:firstKey]; } // Add the object to the dictionary [[dict objectForKey:firstKey] addObject:[[NSMutableDictionary alloc] initWithObjects:item forKeys:[NSArray arrayWithObjects:@"name", @"url", nil]]]; // Add the object to the list for simple searching [fullList addObject:[[NSMutableDictionary alloc] initWithObjects:item forKeys:[NSArray arrayWithObjects:@"name", @"url", nil]]]; } filteredList = [NSMutableArray arrayWithCapacity:[fullList count]]; } #pragma mark - #pragma mark Table view data source // Custom method for object oriented data access - (NSString *)tableView:(UITableView *)tableView dataForRowAtIndexPath:(NSIndexPath *)indexPath withKey:(NSString *)key { return (NSString *)((tableView == self.searchDisplayController.searchResultsTableView) ? [[filteredList objectAtIndex:indexPath.row] objectForKey:key] : [[[dict objectForKey:[listIndex objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row] valueForKey:key]); } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return (tableView == self.searchDisplayController.searchResultsTableView) ? 1 : (([listIndex count] > 0) ? [[dict allKeys] count] : 1); } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return (tableView == self.searchDisplayController.searchResultsTableView) ? [filteredList count] : [[dict objectForKey:[listIndex objectAtIndex:section]] count]; } - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { return (tableView == self.searchDisplayController.searchResultsTableView) ? [[NSArray alloc] initWithObjects:nil] : listIndex; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return (tableView == self.searchDisplayController.searchResultsTableView) ? @"" : [listIndex objectAtIndex:section]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *kCellID = @"cellID"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellID] autorelease]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } NSString * name = nil; // TODO: Make dataForRowAtIndexPath work here if (tableView == self.searchDisplayController.searchResultsTableView) { // NOTE: dataForRowAtIndexPath causes this to crash for some unknown reason. Maybe it is called before viewDidLoad and has no data? name = [[filteredList objectAtIndex:indexPath.row] objectForKey:@"name"]; } else { // This always works name = [self tableView:[self tableView] dataForRowAtIndexPath:indexPath withKey:@"name"]; } cell.textLabel.text = name; return cell; } #pragma mark Search Methods - (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope { // Clear the filtered array [self.filteredList removeAllObjects]; // Filter the array for (NSDictionary *item in fullList) { // Compare the item's name to the search text NSComparisonResult result = [[item objectForKey:@"name"] compare:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchText length])]; if (result == NSOrderedSame) { // Add to the filtered array if it matches [self.filteredList addObject:item]; } } } - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString { [self filterContentForSearchText:searchString scope: [[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]]; // Return YES to cause the search result table view to be reloaded. return YES; } - (void)viewDidUnload { filteredList = nil; } @end

    Read the article

  • php slideshow sample

    - by serhio
    I try to do a simple image slideshow in php (just cycle images, no links, no other effects). after some googling I found the following in net: <HTML> <HEAD> <TITLE>Php Slideshow</TITLE> <script language="javascript"> var speed = 4000; // time picture is displayed var delay = 3; // time it takes to blend to the next picture x = new Array; var y = 0; <?php $tel=0; $tst='.jpg'; $p= "./images"; $d = dir($p); $first = NULL; while (false !== ($entry = $d->read())) { if (stristr ($entry, $tst)) { $entry = $d->path."/".$entry; print ("x[$tel]='$entry';\n"); if ($first == NULL) { $first = $entry; } $tel++; } } $d->close(); ?> function show() { document.all.pic.filters.blendTrans.Apply(); document.all.pic.src = x[y++]; document.all.pic.filters.blendTrans.Play(delay); if (y > x.length - 1) y = 0; } function timeF() { setTimeout(show, speed); } </script> </HEAD> <BODY > <!-- add html code here --> <?php print ("<IMG src='$first' id='pic' onload='timeF()' style='filter:blendTrans()' >"); ?> <!-- add html code here --> </BODY> </HTML> but it displays only the first image from the cycle. Do I something wrong? the resulting HTML page is: <HTML> <HEAD> <TITLE>Php Slideshow</TITLE> <script language="javascript"> var speed = 4000; // time picture is displayed var delay = 3; // time it takes to blend to the next picture x = new Array; var y = 0; x[0]='./images/under_construction.jpg'; x[1]='./images/BuildingBanner.jpg'; x[2]='./images/littleLift.jpg'; x[3]='./images/msfp_smbus1_01.jpg'; x[4]='./images/escalator.jpg'; function show() { document.all.pic.filters.blendTrans.Apply(); document.all.pic.src = x[y++]; document.all.pic.filters.blendTrans.Play(delay); if (y > x.length - 1) y = 0; } function timeF() { setTimeout(show, speed); } </script> </HEAD> <BODY > <!-- add html code here --> <IMG src='./images/under_construction.jpg' id='pic' onload='timeF()' style='filter:blendTrans()' ><!-- add html code here --> </BODY> </HTML>

    Read the article

  • div innerHTML problem with updatepanel

    - by asif
    I have an application developed in asp.net which set innerhtml of div. I am creating an html string to show googlemap. It works fine. But when I put my div inside update panel. it doesnt show googlemap in div. Here is my aspx file code: </td> </tr> <tr> <td colspan="4"> <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> <div id="map_canvas" runat="server" style="width: 100%; height: 1500px; margin-bottom: 2px; text-align: center;"> <asp:Panel ID="Panel1" runat="server"> <%--Place holder to fill with javascript by server side code--%> <asp:Literal ID="js" runat="server"></asp:Literal> <%--Place for google to show your MAP--%> <div id="Div1" style="width: 100%; height: 728px; margin-bottom: 2px;"> </div> <br /> </asp:Panel> </div> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="btnShow" EventName="Click" /> </Triggers> </asp:UpdatePanel> </td> </tr> here is my button click event. protected void btnShow_Click(object sender, EventArgs e) { // works fine without update panel. map_canvas.InnerHtml = showMapWithPoints(); }

    Read the article

  • MySQL database Int overflow and can't login in.

    - by Ryan SMith
    I have a MySQL database on my server and I"m pretty sure it's an int over flow on one table with an auto_increment field that's crashing it. I can delete the table, it's not very important, but I can't get into the server. Is there anyway to delete that database from the file system or without logging into MySQL? HELP! THE WORLD IS ENDING!

    Read the article

  • Calling and leaving gnuplot prompt and png export

    - by ldigas
    a) I have a data file with, well ... data, and a .gnu file with gnuplot commands. If I call gnuplot like this: gnuplot -p commands_file.gnu I'll get the graph on screen and when I close it, gnuplot will be in it's own prompt (gnuplot_). How can I make it just show the graph, and put me back on cmd prompt after I close it ? b) How to "export" that graph to png or something insertable in Word ? I know there are a dozen tutorials for this on the 'net, but I'm having trouble just finding a simple example.

    Read the article

  • Codeigniter ignoring query strings. Only loading

    - by Keyo
    I have setup remote debugging in netbeans. It works except codeigniter only loads the default controller (home page). I have enabled query strings with $config['enable_query_strings'] = TRUE; The debugger opens up a page with the following url http://blinkfilms.ben.dev/myid/tests?XDEBUG_SESSION_START=netbeans-xdebug So codeigniter should fire up the controller in controllers/myid/tests.php

    Read the article

  • Objective C defining UIColor constants

    - by futureelite7
    Hi, I have a iPhone application with a few custom-defined colors for my theme. Since these colors will be fixed for my UI, I would like to define the colors in a class to be included (Constants.h and Constants.m). How do I do that? (Simply defining them does not work because UIColors are mutable, and would cause errors - Initalizer not constant). /* Constants.h */ extern UIColor *test; /* Constants.m */ UIColor *test = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; Thanks!

    Read the article

  • [bash] files indexed by production date

    - by caas
    Each day an application creates a file called file_YYYYMMDD.csv where YYYYMMDD is the production date. But sometimes the generation fails and no files are generated for a couple of days. I'd like an easy way in a bash or sh script to find the filename of the most recent file, which has been produced before a given reference date. Typical usage: find the last generated file, disregarding those produced after the May 1st. Thanks for your help

    Read the article

  • Is there an easier way of creating a registry volatile subkey in .net?

    - by Simon
    So far I have the below which is taken from http://www.danielmoth.com/Blog/volatile-registrykey.aspx public static class RegistryHelper { public static RegistryKey CreateVolatileSubKey(RegistryKey rk, string subkey, RegistryKeyPermissionCheck permissionCheck) { var rk2 = rk.GetType(); const BindingFlags bfStatic = BindingFlags.NonPublic | BindingFlags.Static; const BindingFlags bfInstance = BindingFlags.NonPublic | BindingFlags.Instance; rk2.GetMethod("ValidateKeyName", bfStatic).Invoke(null, new object[] { subkey }); rk2.GetMethod("ValidateKeyMode", bfStatic).Invoke(null, new object[] { permissionCheck }); rk2.GetMethod("EnsureWriteable", bfInstance).Invoke(rk, null); subkey = (string)rk2.GetMethod("FixupName", bfStatic).Invoke(null, new object[] { subkey }); if (!(bool)rk2.GetField("remoteKey", bfInstance).GetValue(rk)) { var key = (RegistryKey)rk2.GetMethod("InternalOpenSubKey", bfInstance, null, new[] { typeof(string), typeof(bool) }, null).Invoke(rk, new object[] { subkey, permissionCheck != RegistryKeyPermissionCheck.ReadSubTree }); if (key != null) { rk2.GetMethod("CheckSubKeyWritePermission", bfInstance).Invoke(rk, new object[] { subkey }); rk2.GetMethod("CheckSubTreePermission", bfInstance).Invoke(rk, new object[] { subkey, permissionCheck }); rk2.GetField("checkMode", bfInstance).SetValue(key, permissionCheck); return key; } } rk2.GetMethod("CheckSubKeyCreatePermission", bfInstance).Invoke(rk, new object[] { subkey }); int lpdwDisposition; IntPtr hkResult; var srh = Type.GetType("Microsoft.Win32.SafeHandles.SafeRegistryHandle"); var temp = rk2.GetField("hkey", bfInstance).GetValue(rk); var rkhkey = (SafeHandleZeroOrMinusOneIsInvalid)temp; var getregistrykeyaccess = (int)rk2.GetMethod("GetRegistryKeyAccess", bfStatic, null, new[] { typeof(bool) }, null).Invoke(null, new object[] { permissionCheck != RegistryKeyPermissionCheck.ReadSubTree }); var errorCode = RegCreateKeyEx(rkhkey, subkey, 0, null, 1, getregistrykeyaccess, IntPtr.Zero, out hkResult, out lpdwDisposition); var keyNameField = rk2.GetField("keyName", bfInstance); var rkkeyName = (string)keyNameField.GetValue(rk); if (errorCode == 0 && hkResult.ToInt32() > 0) { var rkremoteKey = (bool)rk2.GetField("remoteKey", bfInstance).GetValue(rk); var hkResult2 = srh.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(IntPtr), typeof(bool) }, null).Invoke(new object[] { hkResult, true }); var key2 = (RegistryKey)rk2.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { hkResult2.GetType(), typeof(bool), typeof(bool), typeof(bool), typeof(bool) }, null).Invoke(new[] { hkResult2, permissionCheck != RegistryKeyPermissionCheck.ReadSubTree, false, rkremoteKey, false }); rk2.GetMethod("CheckSubTreePermission", bfInstance).Invoke(rk, new object[] { subkey, permissionCheck }); rk2.GetField("checkMode", bfInstance).SetValue(key2, permissionCheck); if (subkey.Length == 0) { keyNameField.SetValue(key2, rkkeyName); } else { keyNameField.SetValue(key2, rkkeyName + @"\" + subkey); } key2.Close(); return rk.OpenSubKey(subkey, true); } if (errorCode != 0) rk2.GetMethod("Win32Error", bfInstance).Invoke(rk, new object[] { errorCode, rkkeyName + @"\" + subkey }); return null; } [DllImport("advapi32.dll", CharSet = CharSet.Auto)] private static extern int RegCreateKeyEx(SafeHandleZeroOrMinusOneIsInvalid hKey, string lpSubKey, int reserved, string lpClass, int dwOptions, int samDesigner, IntPtr lpSecurityAttributes, out IntPtr hkResult, out int lpdwDisposition); } Which works but is fairly ugly. Is there a better way?

    Read the article

  • How do I use a contact's photo in a table view cell?

    - by Andy
    I've got an app that has a table view that displays contact information in each row. I'd like to use the contact's stored image (if there is one available) as the image on the left-hand side of the cell. I've found some sketchy sample code in Apple's documentation, but the address book references some kind of weird data type (CFDataRef) that doesn't appear to correspond to the data types referenced in the table view programming guide (mainly UIImage). This seems like a pretty basic task, but I can't seem to wrap my head around it. Thanks in advance for any help you can offer.

    Read the article

  • Trapping errors in TClientDataSet.CommandText

    - by Rob McDonell
    I have a TClientDataSet connected to a TDataSetProvider, which in turn is connected to a TAdsTable. I set the SQL command and then open the ClientDataset something like this: try CDS.CommandText := 'SELECT * FROM tablename WHERE fieldname = 1'; CDS.Open except // trap exception here - this never gets executed! end; If the SQL statement in CommandText fails, however (syntax error or whatever) I get an exception within the Advantage code, but it never gets caught in my own exception handling code. Is there any way for me to trap this error and report it nicely to the user. Alternatively is there a way to verify the syntax of an SQL query before executing it? I'm using Delphi Pro 2009, and Advantage Local Server 9.

    Read the article

  • Prevent box shadow from showing on a specific side

    - by kaile
    Is there any way to create a css box-shadow in which regardless of the blur value, the shadow only appears on the desired sides? For example if I want to create a div with shadows on left and right sides and no shadow on the top or bottom. The div is not absolutely positioned and its height is determined by the content. -- Edit -- @ricebowl: I appreciate your answer. Maybe you can help with creating a complete solution to fix the problems stated in my reply to your solution... My page setup is as follows: <div id="container"> <div id="header"></div> <div id="content"></div> <div id="clearfooter"></div> </div> <div id="footer"></div> And CSS like this: #container {width:960px; min-height:100%; margin:0px auto -32px auto; position:relative; padding:0px; background-color:#e6e6e6; -moz-box-shadow: -3px 0px 5px rgba(0,0,0,.8), 3px 0px 5px rgba(0,0,0,.8);} #header {height:106px; position:relative;} #content {position:relative;} #clearFooter {height:32px; clear:both; display:block; padding:0px; margin:0px;} #footer {height:32px; padding:0px; position:relative; width:960px; margin:0px auto 0px auto;}

    Read the article

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