Is it possible to read stdin as binary data in Python 2.6? If so, how?
I see in the Python 3.1 documentation that this is fairly simple, but the facilities for doing this in 2.6 don't seem to be there.
If the methods described in 3.1 aren't available, is there a way to close stdin and reopen in in binary mode?
I have a huge disgusting stored procedure that wasn't slow a couple months ago, but now is. I barely know what this thing does and I am in no way interested in rewriting it.
I do know that if I take the body of the stored procedure and then declare/set the values of the parameters and run it in query analyzer that it runs more than 20x faster.
From the internet, I've read that this is probably due to a bad cached query plan. So, I've tried running the sp with "WITH RECOMPILE" after the EXEC and I've also tried putting the "WITH RECOMPLE" inside the sp, but neither of those helped even a little bit.
When I look at the execution plan of the sp vs the query, the biggest difference is that the sp has "Parallelism" operations all over the place and the query doesn't have any. Can this be the cause of the difference in speeds?
Thank you, any ideas would be great... I'm stuck.
I have a rails application, with a model that is a kind of repository.
The records stored in the DB for that model are (almost) never changed, but are read all the time. Also there is not a lot of them.
I would like to store these records in cache, in a generic way.
I would like to do something like acts_as_cached, but here are the issue I have:
I can not find a decent documentation for acts as cached (neither can I find it's repository)
I don't want to use memcached, but something simpler (static variable, or something like that).
Do you have any idea of what gems I could use to do that ?
Thanks
How to get PIDs of processes that are using a given file name and mutex name?
(Not by custom kernel driver, but in C# in user mode.)
UPDATE: Thanks to Daniel Renshaw I found a script that lists all handles with PIDs. (Using a not undocumented and unfrozen functions.)
We have some code that works and it's a Win32 app with a GUI, but I would like to be able to trigger it from the command line as well (silent mode). Is there any easy way to do this? Or do I have to create another project as a command line application?
I want to use mode rewrite to display the following:
mydomain.com/Florida/Tampa/ instead of mydomain.com/place.php?state=Florida&city=Tampa
I've akready done this: (since I think it might make a difference!)
mydomain.com/[name].html instead of mydomain.com/profile?user=[name]
Here is the code!
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{SCRIPT_FILENAME}! !-f
RewriteCond %{SCRIPT_FILENAME}! !-d
RewriteRule (.*).html profile.php?user=$1 [QSA.L]
I am working with Tomcat 5.5.x with Struts 1.2 to run a rather large website (large w.r.t. source code). I'm looking to add OpenID to my website, mostly to access attribute exchange to help accelerate the registration process.
Every Java implementation for OpenID I have attempted to use will cause a ServletException. Tracing this has been very difficult, but it seems merely instancing any class that makes use of Apache HttpClient will cause the crash.
Is this a configuration problem I can address in the JVM, or is it positively wrong to try to initiate an outbound Http request from within an inbound Http request?
Sample jquery. Assume $cog is a cached selector of multiple items.
$cog.fadeOut('slow',function(){
alert('hey');
})
In that example, of $cog is a jQuery object of 4 DOM elements, the above will fade each element out one by one, and trigger an alert each time on the callback (4 alerts).
I'd like to only call the alert when all 4 elements are done with their fadeOut function.
This:
$cog.fadeOut('slow',function(){
})
alert('hey');
when run, will show an alert, then the $cog elements disappear (I'm guessing due to timing issues with the fadeOut animation)
Is there a way when calling a function against multiple DOM objects in a jQuery object to know when it's done with the last item?
Hi
I am new to iphone development. In my application, i want to draw a road map(driving/walking mode) from current location (wherever we are in) into target place which is given by user via textfield. All things should be done inside my application. Is there any idea? or any sample?
I am building a search with the keywords cached in a table. Before a user-inputted keyword is looked up in the table, it is normalized. For example, some punctuation like '-' is removed and the casing is standardized. The normalized keyword is then used to find fetch the search results.
I am currently handling the normalization in the controller with a before_filter. I was wondering if there was a way to do this in the model instead. Something conceptually like a "before_find" callback would work although that wouldn't make sense on for an instance level.
I have a wpf app that needs to communicate(exchange data) with a custom designed device (we can modify the code for the device). Do I have any options to connect to the device if it is behind a firewall via http? I was hoping there would be a method where the admin would not have to forward any specific ports or do anything on his end. I assume the issue is how would I address the device from my app. I know SOAP over SMTP is one option. Is another option where the device could chatter out to my application via http?
Hi
In my mode I am selecting a field as
$query1 = $this->db->query("SELECT dPassword
FROM tbl_login
WHERE dEmailID='[email protected]'");
How to return dpassword as a variable to my controller
I tried this way return dpassword;
Hi guys, thanks in advance for any help on this topic!
I'm sure this has a very simply answer, but I can't seem to find it (not sure what to search on!). A standard count / group by query may look like this:
SELECT COUNT(`t2`.`name`)
FROM `table_1` `t1`
LEFT JOIN `table_2` `t2` ON `t1`.`key_id` = `t2`.`key_id`
GROUP BY `t1`.`any_col`
and this works as expected, returning 0 if no rows are found. So does:
SELECT COUNT(`t2`.`name`)
FROM `table_1` `t1`
LEFT JOIN `table_2` `t2` ON `t1`.`key_id` = `t2`.`key_id`
WHERE `t1`.`another_column` = 123
However:
SELECT COUNT(`t2`.`name`)
FROM `table_1` `t1`
LEFT JOIN `table_2` `t2` ON `t1`.`key_id` = `t2`.`key_id`
WHERE `t1`.`another_column` = 123
GROUP BY `t1`.`any_col`
only works if there is at least one row in table_1 and fails miserably returning an empty result set if there are zero rows. I would really like this to return 0! Anyone enlighten me on this? Beer can be provided in exchange if you are in London ;-)
Hi,
I'm using godaddy shared hosting, with IIS7, Integrated mode, and published up a bog standard MVC2 app to dev.lazygekko.com created with Visual Web Developer 2010.
It all works, however when any of the links are clicked, they point to dev.lazygekko.com/dev/..., dev being the folder it is pointing at.
Can anyone shed some light on what I may be doing wrong?
Many thanks.
I am using an iframe to show the child pages.In that one one particular page contains hidden div and i am showing it as a pop-up like thing with javascript by changing the visibility of the hidden div.
Problem is before showing the hidden div , some manipulations are done at server level and I am calling the div from C# code after the manipulations like
Page.ClientScript.RegisterStartupScript(GetType(), "MyKey", "javascript:OpenModelPopup('cb','cs');", true);
so the page is getting posted back and the div is shown.
after this, after going to next page if i click browser back it shows that page with that hidden div and on next click of browser back gives the page without hidden div.
but I want to show only the initial stage of the page ie. without showing the hidden div
that stage with hidden div should not be cached or it should not be shown on click of browser back.
Is there a simple way to invert a WPF GridView so that items are bound to columns instead of rows? Or would it be necessary to write a custom view mode?
I maintain an application where users are able to store images, and then share them. The system is powered by MongoDB at the back end. Most of the image depiction pages are cached as flat HTML files, but I can run some code just before loading the file.
I've decided to implement a view count for the system. I am wondering what is the best storage place for that. It should be like Memcached but it should save the viewcounts every hour or so, so even if our server has to be restarted we won't lose the view counts.
What is the best solution for that (preferably with a PHP extension as a client)?
i have a j2me application ,
it does the File IO operation, but every time it performs it , it asks user for permission.
is there any way to bypass it?
i heard that suppose if i make this application certified then i would be able to run it in max. secure mode to bypass such issues.
I am using a Jquery dialog for both viewing a record and editing a record. When in edit mode the user can change the date using the datepicker. In viewmode I need to hide the datepicker icon and only show the date. Is there a way to toggle the datepicker icon on and off as needed?
I noticed that some enumerations have "None" as a enumeration member.
For example what I mean
enum Mode
{
Mode1 = 1,
Mode2 = 2,
Mode3 = 3,
None = 4
}
Why do they use it ? In what cases solution with a none member is more preferable (less preferable) ?
I'm making a webapp, and I'd like an input field to show the Iphone's number keypad.
I understand that type=number will make the keypad show the way I'd like.
The trouble is that type=number does not support placeholder text. So if I would like this:
Expiration Date:
[eg: 2010]
I can not get it to work, and also show the right keyboard.
Is there a way to force the iphone keyboard into number mode without using the number input type?
I'm using C# and probably .Net compact framework. How should I design mobile news reader (RSS, Atom...).
What are risks I should be aware before I start?
What libraries are there to help me read and parse data and synchronize it when going from offline mode?
#include <stdio.h>
//Here use a macro definition that assigns a value to SIZE (for example 5)
int main()
{
int i;
int array[SIZE];
int sum=0;
for(i=0; i<SIZE; i++)
{
//Here use a macro definition named as CALCSUM to make the
//following addition operation for the array
printf("Enter a[%d] = ",i);
scanf("%d", &array[i]);
sum+=array[i];
//Here use a macro definition named as VERBOSE to print
//what program does to the screen
printf("The user entered %d\n", array[i]);
//
//
//If the macro definition CALCSUM is not used, the program
//should assign 0 to the i-th element of the array
array[i]=0;
//Here, again use VERBOSE to print what program does to the screen
printf("a[%d] is assigned to zero\n", i);
//
//
}
//If CALCSUM is defined, print the summation of the array elements to the screen
printf("Summation of the array is %d\n",sum);
//
//If CALCSUM is not defined, but VERBOSE mode is used, print the following
printf("All the elements in the array are assigned to zero\n");
//
printf("Program terminated\n");
return 0;
}
When CALCSUM is defined, the program will sum up the values of each element in the given array.
If CALCSUM is not defined, each array element will be assigned to zero.
Besides, when VERBOSE mode is defined, the program will make print statements pointed out active.
[root@linux55]# gcc code.c
[root@linux55]# ./a.out
Program terminated
[root@linux55]# gcc code.c -D CALCSUM
[root@linux55]# ./a.out
Enter a[0] = 3
Enter a[1] = 0
Enter a[2] = 2
Enter a[3] = 5
Enter a[4] = 9
Summation of the array is 19
Program terminated
[root@linux55]# gcc code.c -D CALCSUM -D VERBOSE
[root@linux55]# ./a.out
Enter a[0] = 2
The user entered 2
Enter a[1] = 10
The user entered 10
Enter a[2] = 3
The user entered 3
Enter a[3] = 8
The user entered 8
Enter a[4] = 1
The user entered 1
Summation of the array is 24
Program terminated
[root@linux55]# gcc code.c -D VERBOSE
[root@linux55]# ./a.out
a[0] is assigned to 0
a[1] is assigned to 0
a[2] is assigned to 0
a[3] is assigned to 0
a[4] is assigned to 0
All the elements in the array is assigned to zero
Program terminated