Daily Archives

Articles indexed Monday September 17 2012

Page 4/17 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Django finding which field matched in a multiple OR query

    - by Greg Hinch
    I've got a couple models which are set up something like this: class Bar(models.Model): baz = models.CharField() class Foo(models.Model): bar1 = models.ForeignKey(Bar) bar2 = models.ForeignKey(Bar) bar3 = models.ForeignKey(Bar) And elsewhere in the code, I end up with an instance of Bar, and need to find the Foo it is attached to in some capacity. Right now I came up with doing a multiple OR query using Q, something like this: foo_inst = Foo.objects.get(Q(bar1=bar_inst) | Q(bar2=bar_inst) | Q(bar3=bar_inst)) What I need to figure out is, which of the 3 cases actually hit, at least the name of the member (bar1, bar2, or bar3). Is there a good way to do this? Is there a better way to structure the query to glean that information?

    Read the article

  • Build SUM based daily record

    - by ximarin
    I have a problem building an aggregate function. Here's my problem: I have a table like this id action day isSum difference 1 ping 2012-01-01 1 500 (this is the sum of the differences from last year) 2 ping 2012-01-01 0 -2 3 ping 2012-01-02 0 1 4 ping 2012-01-03 0 -4 5 ping 2012-01-04 0 -2 6 ping 2012-01-05 0 3 7 ping 2012-01-06 0 2 8 ping 2012-01-01 1 0 (this is the sum of the differences from last year, now for pong) 9 pong 2012-01-01 0 -5 10 pong 2012-01-02 0 2 11 pong 2012-01-03 0 -2 12 pong 2012-01-04 0 -8 13 pong 2012-01-05 0 3 14 pong 2012-01-06 0 4 I now need to select the action, day and the summarized difference since 01-01 for every day, so that my result looks like this action day total ping 2012-01-01 498 ping 2012-01-02 499 ping 2012-01-03 495 ping 2012-01-04 493 ping 2012-01-05 496 ping 2012-01-06 498 pong 2012-01-01 - 5 pong 2012-01-02 - 3 pong 2012-01-03 - 5 pong 2012-01-04 -13 pong 2012-01-05 -10 pong 2012-01-06 - 6 How can I do this? there a are a lot of datasets (~1 million), so the query needs to be pretty cheap. I don't know how the use sum to get daily sums for daily records depending on the action-column.

    Read the article

  • why is there extra using where in execution plan of query

    - by user366534
    I see plan of query: EXPLAIN SELECT * FROM `subscribers` WHERE state =4 AND date_added < '2010-12-23 11:47:45' It shows: id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE subscribers range state_date_added state_date_added 9 NULL 8 Using where Here is indexes of table: Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment subscribers 0 PRIMARY 1 subscriber_id A 382039 NULL NULL BTREE subscribers 0 email_list_id 1 email_address A 191019 NULL NULL BTREE subscribers 0 email_list_id 2 list_id A 382039 NULL NULL BTREE subscribers 1 FK_list_id 1 list_id A 10 NULL NULL BTREE subscribers 1 state_date_added 1 state A 12 NULL NULL BTREE subscribers 1 state_date_added 2 date_added A 8128 NULL NULL BTREE The last two lines describes index what is supposed for the query. Why is there in extra column using where? Even If I fetch only state and date_added column, it has in extra column: Using where; Using index. I understand why it has using index, but I don't understand Using where here.

    Read the article

  • Unable to get data from content in jQuery?

    - by Srikanth Chilukuri
    I have 2 HTML files and 2 js files. In App.html I want to include login.html and need to fetch the data from login.html and need to use in in App. App.html <!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Insert title here</title> <script type="text/javascript" src='js/jquery.js'></script> <script type="text/javascript" src="js/app.js"></script> <script type="text/javascript" src="js/login.js"></script> </head> <body> <div id="content"></div> </body> </html> Login.html <!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Insert title here</title> <script type="text/javascript" src='js/jquery.js'></script> </head> <body> <div> <div data-role="fieldcontain"> <label for="userid" id="luserid" ><strong>UserId : </strong></label> <input type="text" name="userid" id="userid" value="" class="logon" placeholder="Username" required/> </div> <div data-role="fieldcontain"> <label for="password" id="lpassword"><strong>Password :</strong></label> <input type="password" name="password" id="password" class="logon" value="" placeholder="Password" required/> </div> <div class="ui-body"> <fieldset class="ui-grid-a"> <div class="ui-block-a"><a data-role="button" id="loginbtn" data-theme="b">Login</a></div> </fieldset> </div> </div> </body> </html> app.js $(document).ready(function(){ $('#content').load('login.html'); }); login.js $(document).ready(function(){ var userid= $("#userid").val(); var upassword= $("#password").val(); alert(userid); alert(upassword); }); Please help me out on this. Note: I do not want to include the login.js in the Login.html.

    Read the article

  • Given an even number of vertices, how to find an optimum set of pairs based on proximity?

    - by Alex Z
    The problem: We have a set of n vertices in 3D euclidean space, and there is an even number of these vertices. We want to pair them up based on their proximity. In other words, we'd like to be able to find a set of vertex pairs, where the vertices in each pair are as close as possible together. We want to minimise sacrificing the proximity between the vertices of any other pairs as much as possible in doing this. I am not looking for the most optimal solution (if it even strictly exists/can be done), just a reasonable one that can be computed relatively quickly. A relatively awful brute force approach involves choosing a vertex and looping through the rest to find its nearest neighbor and then repeating until there are none left. Of course as we near the end of the list the closest vertex could be very far away, but it is the only choice, therefore this can fail badly on the third point above.

    Read the article

  • how to use dropnet, sharpbox and othere libraries in Monodroid

    - by sujit
    I have created on image uploader as a desktop application. Now I want to port it to Android using Monodroid. Application uploads images to dropbox. In the desktop version I have used "dropnet" which references "sharpbox", "Json", etc. Is there any way I can use those i.e. dropnet, sharpbox, etc in my monodroid app? It will take very long if I have to recode those libraries already available in .net . thanks. Sujit

    Read the article

  • Improve performance writing 10 million records to text file using windows service

    - by user1039583
    I'm fetching more than 10 millions of records from database and writing to a text file. It takes hours of time to complete this operation. Is there any option to use TPL features here? It would be great if someone could get me started implementing this with the TPL. using (FileStream fStream = new FileStream("d:\\file.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite)) { BufferedStream bStream = new BufferedStream(fStream); TextWriter writer = new StreamWriter(bStream); for (int i = 0; i < 100000000; i++) { writer.WriteLine(i); } bStream.Flush(); writer.Flush(); // empty buffer; fStream.Flush(); }

    Read the article

  • WordPress + Facebook comments addition (php knowledge needed)

    - by user1356223
    I succeded to fetch Facebok comments number via this function: <?php function fb_comment_count() { global $post; $url = get_permalink($post->ID); $filecontent = file_get_contents('https://graph.facebook.com/?ids=' . $url); $json = json_decode($filecontent); $count = $json->$url->comments; if ($count == 0 || !isset($count)) { $count = 0; } echo $count; } ;?> And I call it with: <?php fb_comment_count();?> Now how do I add it to this code: <?php comments_number(__('No Comments'), __('1 Comment'), __('% Comments'), '', __('Comments Closed') ); ?> so that WordPress shows number of WP and FB comments together in one number. Thank you very much to everyone!

    Read the article

  • Resizing the Camera Preview

    - by uday
    I have implemented a camera application, which will show the preview in the entire screen of the device. But my requirement is to show the Camera preview in a small screen. My device resolution is 800x480(WxH) i.e, Nexus one. I can able to show the preview in the entire screen without scale down the preview. Its coming perfectly, but when i try show the preview in small screens(part of my total mobile screen), the preview is getting stretched and not looking good. Is there any way to show the preview correctly in a small screen. I think we need to scale down the image preview. But when i try to scale down the image preview, the android system itself doesn't allowing to set the scaled preview size. Could any one please help me how to scale the image preview in small screen.

    Read the article

  • mmc could not create the snap-in. CLSID: FX:{18ea3f92-d6aa-41d9-a205-2023400c8fbb} error

    - by Tammy
    MMC Snap-in will not load most processes and throws an error on Windows 2008R2 x64. It gives the error: mmc could not create the snap-in. CLSID: FX:{18ea3f92-d6aa-41d9-a205-2023400c8fbb} when opening server manager. It also gives similar errors opening event viewer, etc. I think that the .NET Framework is messed up but I can't narrow down the exact cause. Has anyone else seen this issue. I have a dmp file of mmc.exe but haven't been able to get anything meaningful out of it.

    Read the article

  • in_array() and multidimensional array

    - by lauthiamkok
    I use in_array() to check whether a value exists in an array like below, $a = array("Mac", "NT", "Irix", "Linux"); if (in_array("Irix", $a)) { echo "Got Irix"; } //print_r($a); but what about an multidimensional array (below) - how can I check that value whether it exists in the multi-array? $b = array(array("Mac", "NT"), array("Irix", "Linux")); print_r($b); or I shouldn't be using in_array() when comes to the multidimensional array?

    Read the article

  • WPF ICommand over a button

    - by toni
    I have implemented a custom IComand class for one of my buttons. The button is placed in a page 'MyPage.xaml' but its custom ICommand class is placed in another class, not in the MyPage code behind. Then from XAML I want to bind the button with its custom command class and then I do: MyPage.xaml: <Page ...> <Page.CommandBindings> <CommandBinding Command="RemoveAllCommand" CanExecute="CanExecute" Executed="Execute" /> </Page.CommandBindings> <Page.InputBindings> <MouseBinding Command="RemoveAllCommand" MouseAction="LeftClick" /> </Page.InputBindings> <...> <Button x:Name="MyButton" Command="RemoveAllCommand" .../> <...> </Page> and the custom command button class: // Here I derive from MyPage class because I want to access some objects from // Execute method public class RemoveAllCommand : MyPage, ICommand { public void Execute(Object parameter) { <...> } public bool CanExecute(Object parameter) { <...> } public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } } My problem is how to say MyPage.xaml that Execute and CanExecute methods for the button is in another class and not the code behind where is placed the button. How to say these methods are in RemoveAllCommand Class in XAML page. Also I want to fire this command when click mouse event is produced in the button so I do an input binding, is it correct? Thanks

    Read the article

  • How to: Apply themes using Server Object Model in SharePoint 2013 Preview

    - by panjkov
    One of new functionalities introduced in SharePoint 2013 Preview is new theming engine. Themes that are managed by this new engine don’t use Office Theme .thmx format and can’t be created using PowerPoint like it was case before. New themes are based on set of xml files stored in Theme Gallery “15” subfolder (on relative path _catalogs/theme/15): .spcolor files  which define color palettes for components of SharePoint interface .spfont files which contain set of predefined font schemes. There...(read more)

    Read the article

  • Font display issue (Mac OS X)?

    - by avenas8808
    I used a font manager on Mac OS X, for additional fonts in my graphic design projects without installing them to the fonts folder (I think that's how it works) - using Font Book and Font Explorer X Version 1.2.3 on OS X 10.6. Most fonts work fine, but Interstate has a problem: Interstate Regular is installed, but for some reason it's probably not seeing it; it's seeing all the Bold and Condensed versions fine. In the above image, it displays the second font as Interstate Regular, but it isn't that font... why? Also, how do I reset the system fonts folder back to the default-installed fonts (I think it's in the library folder) if worst comes to worst, and is using a font manager on Mac or Windows a good idea? I don't want to wreck my system, fairly new to using Mac, especially OS X, so any help would be gratefully accepted.

    Read the article

  • Preventing h/w RAID cards from dropping slow JBOD disks

    - by Kevin
    I'm considering buying a used SAS h/w RAID card for externally attaching HDDs to an HP ProLiant I'm setting up. However, I only require RAID functionality on some of the drives. Theoretically it should be simple to JBOD the other drives, but some of them are inexpensive SATA disks and probably cannot have TLER disabled. I'd like to know, prior to actually ordering a RAID card, whether typically RAID cards would still enforce dropping of disks that do not respond within a few seconds, even if the disk is in a JBOD, and whether there is any way to disable this. Ideally it would be nice to be able to select certain SAS ports that will be pass-through, bypassing the RAID engine entirely and just acting as an HBA for those ports. I know I could buy a separate SAS HBA but that seems like a waste of $ and is also impractical as it's a 1U server so space is extremely limited. My question then is whether the functionality I'm looking for (pass-through on certain ports or at least JBOD drives not getting themselves dropped due to slow response) is typical of proper h/w RAID cards such as PERC 5/E etc. I've browsed through the latter's manual but unfortunately, as with most user manuals, it states the obvious and doesn't state the unobvious. Thanks for any info, Kevin

    Read the article

  • When and how often to start connection to database in php?

    - by AndHeiberg
    When and how often is it good practice to start the connection to your database in php? I'm new to databases, and I'm wondering when I should start by database connection. I'm creating a api with an index, controllers and model. Should I start the connection in the index and then pass it to all the other files, start the connection at the top of all files and call it as a global in functions as needed or start and end the connection in every function?

    Read the article

  • Remote Desktop *from* Windows 2008 R2 Server

    - by freefaller
    Summary: how do I create an RDC connection from a Windows 2008 server to another server? Our client will only allow us to connect to their server via a static IP address (which is fair enough), but unfortunately as we're a very small company we don't have one in the office. As a work around, we had the connection working through our old Windows 2003 server (dynamic-cloud from 1and1). .. however we have just rebuilt the server to run under Windows 2008 R2 (don't ask, but it was necessary), and now I simply cannot get the connection working. I have added an "Outbound Rule" to Windows Firewall with Advanced Security (TCP, All local ports, 3389 remote port - I have also tried the other way around). I have added a packet filter IP security rule with the same details. The 1and1 firewall rules (through their online control panel) allows for 3389 TCP and UDP. But it is simply not connecting (yes, the server is definitely on and able to accept connections) with the general error of... Remote Desktop can’t connect to the remote computer for one of these reasons: 1) Remote access to the server is not enabled 2) The remote computer is turned off 3) The remote computer is not available on the network Is there anything obvious I've missed - or something I can use to find out where the request is being blocked? The new server is using the exact same IP address as before, so I don't believe that would be an issue. Unless it's trying to use an IPv6 address rather than the old IPv4 address that it was before? I apologise that I am not a network person by trade, but I know more than anybody else in my office!!

    Read the article

  • Apache 2.2 Present rss http 410 pages as application/rss+xml content type

    - by Mark Bakker
    I have a problem sending http-410 for very old rss feeds. Functional this can happen in one Very old rss feeds where content is not updated anymore / subject could not move to another feed Migration from 3th party site to our site where the rss feed is not longer functional supported I tried several things in my site config see below; <VirtualHost *:80> DocumentRoot /opt/tomcat/webapps/ROOT/ ErrorDocument 500 /error/static/error-500.html ErrorDocument 503 /error/static/error-500.html ErrorDocument 404 /error/static/rss/error-404.html ErrorDocument 410 /error/static/rss/error-410.html # When error pages need to be served by apache, # exclude the files to serve as below (in comment) SetEnvIf Request_URI "/error/static/*" no-jk # force all files to be image/gif: <Location *.rss> #<Location *> #ForceType application/rss+xml </Location> #AddType application/rss+xml .rss #AddType application/rss+xml .xml #AddType application/rss+xml .html JkMount /* rss;use_server_errors=402 # JkMount /* rss RewriteEngine on JkMount /news.rss rss JkMount /documenten-en-publicaties.rss rss RewriteEngine on RewriteRule ^/news.rss$ - [NC,T=application/rss+xml,G,L] RewriteRule ^/documenten-en-publicaties.rss$ - [NC,G,L] # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn ErrorLog "|/usr/bin/logger -s -p local3.err -t 'Apache'" CustomLog "|/usr/bin/logger -s -p local2.info -t 'Apache'" combined ServerSignature Off </VirtualHost> The desired end result should be on /news.rss and /documenten-en-publicaties.rss a 410 page with content in the error page with a content type 'application/rss+xml'

    Read the article

  • Server App - Users

    - by Benno
    I'm using mac OSX lion server, and I'm trying to setup a user account with access to different services. I had to create the user in Prefs users and groups, because it wouldn't work in the Server app. In the server app, it kept saying "This operation couldn't be completed". I managed to create the user in the system prefs, but now I'm back in the server app and cannot update the services the user has access to. The checkboxes are all there for e.g. Address book, file sharing etc, but I can't deselect any of them... Any ideas on why I can't change a user's access to services?

    Read the article

  • prevent search engines indexing depending on domain

    - by Javier
    We have a dedicated server with a hosting company with a couple of dozens of webs in it. It happens that the nameservers (EG: ns1.domain.com, ns2.domain.com) ip's are coincident with some client webs, let's say webclient1.com and webclient2.com Problem is that for a certain searches in google, some results are showing up like ns1.domain.com/result instead of webclient1.com/result which is pretty wrong and annoying for our clients. Actually if you type in the browser ns1.domain.com or ns2.domain.com it will load some pageclients instead. Is there any way to prevent google to track those results only in case the robots are coming to check ns domains? It may be not correct to ask this as well, but why is it happening? is it a result of a bad server configuration? I'm pretty new on these matters, so thank you in advance for any help!

    Read the article

  • Puppet master fails to run under nginx+passenger configuration as rack app, works when run as system service

    - by Anadi Misra
    I get the error [anadi@bangda ~]# tail -f /var/log/nginx/error.log [ pid=19741 thr=23597654217140 file=utils.rb:176 time=2012-09-17 12:52:43.307 ]: *** Exception LoadError in PhusionPassenger::Rack::ApplicationSpawner (no such file to load -- puppet/application/master) (process 19741, thread #<Thread:0x2aec83982368>): from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from config.ru:13 from /usr/local/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval' from /usr/local/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize' from config.ru:1:in `new' from config.ru:1 when I start nginx server with passenger module configured, puppet master configured to run through rack. here is the config.ru [anadi@bangda ~]# cat /etc/puppet/rack/config.ru # a config.ru, for use with every rack-compatible webserver. # SSL needs to be handled outside this, though. # if puppet is not in your RUBYLIB: #$:.unshift('/usr/share/puppet/lib') $0 = "master" # if you want debugging: # ARGV << "--debug" ARGV << "--rack" require 'puppet/application/master' # we're usually running inside a Rack::Builder.new {} block, # therefore we need to call run *here*. run Puppet::Application[:master].run and the nginx configuration for puppet master is as follows [anadi@bangda ~]# cat /etc/nginx/conf.d/puppet-master.conf server { listen 8140 ssl; server_name bangda.mycompany.com; passenger_enabled on; passenger_set_cgi_param HTTP_X_CLIENT_DN $ssl_client_s_dn; passenger_set_cgi_param HTTP_X_CLIENT_VERIFY $ssl_client_verify; access_log /var/log/nginx/puppet/master.access.log; error_log /var/log/nginx/puppet/master.error.log; root /etc/puppet/rack/public; ssl_certificate /var/lib/puppet/ssl/certs/bangda.mycompany.com.pem; ssl_certificate_key /var/lib/puppet/ssl/private_keys/bangda.mycompany.com.pem; ssl_crl /var/lib/puppet/ssl/ca/ca_crl.pem; ssl_client_certificate /var/lib/puppet/ssl/certs/ca.pem; ssl_ciphers SSLv2:-LOW:-EXPORT:RC4+RSA; ssl_prefer_server_ciphers on; ssl_verify_client optional; ssl_verify_depth 1; ssl_session_cache shared:SSL:128m; ssl_session_timeout 5m; } however when I run puppet through the ususal puppetmasterd daemon it works perfect with no errors. I can see somehow the nginx+passenger+rack setup fails to initialize while the same works when running the natvie puppetmaster daemon. Any configuration that I am missing?

    Read the article

  • How do I choose the number of connection for load balancer?

    - by user105196
    I want to add hardware load balancer for apache and I want to know how many people are connected to my server to to choose the type of load balancer: Local Load Balancing with SSL - 250 Connections Local Load Balancing with SSL - 500 Connections Local Load Balancing with SSL - 1000 Connections I run the following commands in the same time: netstat -nt|grep -c :443 ( all connection wait and ESTABLISHED) result : 1208 netstat -ant | grep 443 | grep EST | wc -l ( just ESTABLISHED connection) result :106 My question: Whichever is the correct value to choose the load balancer all connection or just ESTABLISHED ?

    Read the article

  • What is the relation between NetworkManager and network service in Fedora/RHEL/Centos?

    - by Patrick L
    Hi I am new to Fedora/Centos/RHEL. I am confused about NetworkManager and network service in these Linux OS. May I know what is the relation between NetworkManager and network service? If I am using NetworkManager, do i need to turn off network service? Similarly, if I am using network service, do I need to turn off NetworkManager? Will they conflict with each other if I use both application at the same time?

    Read the article

  • MySQL Server hitting 100% unexpectedly (Amazon AWS RDS)

    - by Luc
    Please help! We've been struggling with this one for months. This week we upped our RDS instance to the highest performing instance and although the occurrences have reduced, we're still having our DB all of a sudden hit 100%. It comes out of nowhere. Sometimes 2am, sometimes midday. I've ruled out a DOS - our pages access logs have normal traffic I've ruled out memcached suddenly dieing (hits and misses continue as normal). The SHOW PROCESSLIST while we have issues reports about 500 queries in queue. If I kill them off or restart the server, they just keep coming back and then eventually out of knowhere, our server resumes back to normal. Sometimes up to 3 hours. Our bad performing queries take .02 seconds to execute when the server eventually returns back to normal but while we're in this 100% CPU physco phase, those queries never finish executing. Please help!!!!! Anybody know anything about MYSQL query optimization? Could it be the server deciding to use different indexes all of a sudden, which puts it into a spiral?

    Read the article

  • Error in install sql server 2008 rn

    - by Ahmad Karimi
    When running the SQL Server 2008 setup, I receive the following error message: TITLE: Microsoft SQL Server 2008 R2 Setup The following error has occurred: Unable to open Windows Installer file 'H:\Enterprise\x86\setup\sql_engine_core_inst_msi\sql_engine_core_inst.msi'. Windows Installer error message: The system cannot open the device or file specified. . Click 'Retry' to retry the failed action, or click 'Cancel' to cancel this action and continue setup. For help, click: http://go.microsoft.com/fwlink?LinkID=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=10.50.1600.1&EvtType=0xC24842DB BUTTONS: &Retry Cancel I install the installer 4.5 and restart windows but don't resolve problem.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >