What's the cleanest way of editing the characters in a string in C#?
What's the C# equivalent of this in C++:
std::string myString = "boom";
myString[0] = "d";
I'm trying to create a grouped table view with two sections. For the first section I would like the width to be only half the screen. For the second section it would be the standard width. Also, next to the first section I would like to put a button.
How is this done?
Thanks!
Hi,
My issue is that multiple websites are going to include my JS file and when calling something like this:
<script src="..."></script>
hello.say("yay");
there going to be a race issue so sometimes it could make it sometimes not. i know that i can solve that easily by putting every function in a window.onload but that wouldn't be clean as i've seen other websites magically solve that like google analytics:
.. Calling google analytics JS..
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-xxxxxx-x"); <-- this an object !
pageTracker._trackPageview();
} catch(err) {}
</script>
How to do that?
Is there some way to ask Mercurial to show the revisions being diffed in the output? For example:
$ hg diff -r trunk:development
diff -r 08d51ecf22cf:ff5673e55b9f --git a/foo.c b/foo.c
...
Or something similar?
I've found that there have been a few times that I've taken a diff (eg, to review), but have later been unable to recreate it because I've forgotten which revisions it was taken against.
Is there a way to get the spell checker to properly check camel cased words? "ThisIsSpelledRightly" would be marked as spelled correctly, but "ThisIsNottSpeledRihgt" would be flagged?
I use Xubuntu and firefox.
I tried asking this over on superuser, but it got ignored.
So yesterday we had a table that has an auto_increment PK for a smallint that reached its maximum. We had to alter the table on an emergency basis, which is definitely not how we like to roll.
Is there an easy way to report on how close each auto_increment field that we use is to its maximum? The best way I can think of is to do a SHOW CREATE TABLE statement, parse out the size of the auto-incremented column, then compare that to the AUTO_INCREMENT value for the table.
On the other hand, given that the schema doesn't change very often, should I store information about the columns' maximum values and get the current AUTO_INCREMENT with SHOW TABLE STATUS?
After test driving Google Chrome for 30 minutes or so, I like it, even if it seems bare-bones at the moment. The obvious way to add a few things I can't live without would be through plugins. Does anyone have any links to resources on how to get started building a plugin/addon for Chrome? Thanks.
What is the preferred and/or correct way to release an NSMutableString (or any other class for that matter) instance and assign a new instance to the same variable in Objective-C on the iPhone?
Currently I'm using
[current release];
current = [NSMutableString new];
but I understand that the following works, too.
NSMutableString *new = [NSMutableString new];
[current release];
current = [new retain];
[new release];
The variable current is declared in the interface definition of my class and gets released in dealloc.
Let's say I have a thread pool containing X items, and a given task employs Y of these items (where Y is much smaller than X).
I want to wait for all of the threads of a given task (Y items) to finish, not the entire thread pool.
If the thread pool's execute() method returned a reference to the employed thread I could simply join() to each of these Y threads, but it doesn't.
Does anyone know of an elegant way to accomplish this? Thanks.
How do you even look at the web.config file? I don't know where to go to turn custom errors off...help!
I tried command prompt and java script....can any one help me?
in java is the name of a method a string? why or why not?
so if i have something like:
public static int METHODNAME (some parameters or not)
{
something to do ;
}
is METHODNAME a string?
Consider a table like
tbl_ranks
--------------------------------
family_id | item_id | view_count
--------------------------------
1 10 101
1 11 112
1 13 109
2 21 101
2 22 112
2 23 109
3 30 101
3 31 112
3 33 109
4 40 101
4 51 112
4 63 109
5 80 101
5 81 112
5 88 109
I need to generate a result set with the top two(2) rows for a subset of family ids (say, 1,2,3 and 4) ordered by view count.
I'd like to do something like
select top 2 * from tbl_ranks where family_id = 1 order by view_count
union all
select top 2 * from tbl_ranks where family_id = 2 order by view_count
union all
select top 2 * from tbl_ranks where family_id = 3 order by view_count
union all
select top 2 * from tbl_ranks where family_id = 4 order by view_count
but, of course, order by isn't valid in a union all context in this manner. Any suggestions? I know I could run a set of 4 queries, store the results into a temp table and select the contents of that temp as the final result, but I'd rather avoid using a temp table if possible.
Note: in the real app, the number of records per family id is indeterminate, and the view_counts are also not fixed as they appear in the above example.
How would you unit test do_int_to_string_conversion?
#include <string>
#include <iostream>
void do_int_to_string_conversion(int i, std::string& s) {
switch(i) {
case 1:
s="1";
break;
case 2:
s="2";
break;
default:
s ="Nix";
}
std::cout << s << "\n";
}
int main(int argc, char** argv){
std::string little_s;
do_int_to_string_conversion(1, little_s);
do_int_to_string_conversion(2, little_s);
do_int_to_string_conversion(3, little_s);
}
Hi,
I'm working on a quite big magento: it will have 50 different shops (1 magento install, 1 admin to rule them all) for start, this number is expected to raise in the future, and a catalog of more than 1k products. This catalog will be shared by all shops.
I'm concerned about the server requirements I need for this to run smoothly. So far this is what I've found to get the most of it:
Caching: using magento's cache with APC, MySQL's querys
Images sprite in the theme
use FastCGI instead of mod_php
database clustering: I don't think it will be necesary for 1k products, what do you think?
using Zend Server
Are there other thing I can do in order to improve magento's performance? I'd like to know all I need from the beginning so I can find the right server.
thanks in advance.
Is there an easy way to get a summary string of the errors that have been added to a controller's modelstate?
I'm looking to return this in an Ajax method and want the validation errors etc to be returned to the client (i.e. the view does not exist for this method call).
Or do I have to loop through the modelstate and look at each object and extract the error text manually?
I need to work with TagLib for my project. I've created a framework (and I tried using it as a lib) but the compiler cannot find #include < strings on compiling (No such file or Directory). I've created a test C++ project and it #includes < strings just fine. I've looked at the project settings and I cannot find a difference between them. But the standard cocoa projects obviously so not have the search path set to include C++ libraries (Or am I completely getting it wrong?).
I've searched for a solution but no one else seems to have run into this problem.
im using hibernate with my jsp page and mySQL ,how can i do that select * from student wher userName = *** with HQL
and how i chek if that username exist in 'Student' table ?
in my sql i use that
ResultSet resultat = statement.executeQuery();
if (resultat.next()) { ....}
i try this
Session hibernateSession = MyDB.HibernateUtil.currentSession();
hibernateSession.find("select xxx from Etudinat where p.Nom=xxxx");
thats give an exception so how can i do that ?
i have a login form send me a username and password
i want to chek if that username exist in the table Student to set the user on a session
what is the safty way to do that
Hi,
Basically what I have here is a button that adds a new list item to an unordered list. Within this list item is a dropdown box (.formSelector) that when changed triggers an ajax call to get the values for another dropdown box (.fieldSelector) in the same list item.
The problem is on this line:
$(this).closest(".fieldSelector").append(
If I change it to
$(".fieldSelector").append(
the second box updates correctly. The problem with this is that when I have multiple list items it updates every dropdown box on the page with the class fieldSelector, which is undesirable. How can I traverse the DOM to just pick the fieldSelector in the current list item? Any help is greatly appreciated.
Complete code:
$("button", "#newReportElement").click(function() {
$("#reportElements").append("<li class=\"ui-state-default\"> <span class=\"test ui-icon ui-icon-arrowthick-2-n-s \"></span><span class=\"ui-icon ui-icon-trash deleteRange \"></span> <select name=\"form[]\" class=\"formSelector\"><? foreach ($forms->result() as $row) { echo "<option value='$row->formId'>$row->name</option>"; }?></select><select class=\"fieldSelector\" name=\"field[]\"></select></li>");
$(".deleteRange").button();
$('.formSelector').change(function() {
var id = $(this).val();
var url = "<? echo site_url("report/formfields");?>" + "/" + id;
var atext = "ids:";
$.getJSON(url,
function(data){
$.each(data.items, function(i,item){
$(this).closest(".fieldSelector").append(
$('<option></option>').val(item.formId).html(item.formLabel)
);
});
});
});
return false;
});
I have a need to design a system to track users memberships to groups with varying roles (currently three).
class Group < ActiveRecord::Base
has_many :memberships
has_many :users, :through => :memberships
end
class Role < ActiveRecord::Base
has_many :memberships
has_many :users, :through => :memberships
end
class Membership < ActiveRecord::Base
belongs_to :user
belongs_to :role
belongs_to :group
end
class User < ActiveRecord::Base
has_many :memberships
has_many :groups, :through => :memberships
end
Ideally what I want is to simply set
@group.users << @user
and have the membership have the correct role. I can use :conditions to select data that has been manually inserted as such :
:conditions => ["memberships.grouprole_id= ? ", Grouprole.find_by_name('user')]
But when creating the membership to the group the grouprole_id is not being set.
Is there a way to do this as at present I have a somewhat repetitive piece of code for each user role in my Group model.
There are many discussions about what people's favourite source control is (subversion, mercurial ...). But what source control systems have you used that you certainly wouldn't recommend? And more beneficial, how would you go about promoting change in the business to a new source control system?
A few years ago I developed using a source control system called Synergy. There were two Synergy experts in the company that constantly had to help the developers do check-ins/outs and merges were especially difficult.
What would be your steps of migrating to a better source control. Would you host everything internally or pay for services such as github?
When I first start one of my Wordpress blogs, I had the permanent URL for each post include the date of posting.
The slug format looked like this:
/blog/2010/01/25/this-is-my-article/
Later on, I changed it so that the date was not included in the permanent URL, like this:
/blog/this-is-my-article/ and setup a redirect plugin to make sure that users would get to the page they wanted until the site was re-indexed.
In Google Analytics, when I review the stats for content I now have multiple records for what is essentially the same page. ie:
Top Content List:
45 Pageviews- /blog/this-is-my-article/
24 Pageviews- /blog/2010/01/25/this-is-my-article/
33 Pageviews- /blog/some-other-article/
Is there any way to combine those records somehow?
What I am doing is replacing, in a large program, all $_REQUEST['var'] and mysql_escape_string($_REQUEST['var']) with either the 1st or 2nd line below the dotted line.
Now, I have figured out this much of the regular expression but I would like to make it simpler. Instead of having to run the top one first then the 2nd one I would like to just run one all together. I tried this but it did not work.
(mysql_escape_string\()*$_REQUEST\[\'([^']*)\'\]\)(\)*)
So below is what works but again have to do it twice.
$_REQUEST\[\'([^']*)\'\]
mysql_escape_string\($_REQUEST\[\'([^']*)\'\]\)
(isset($_GET['\1'])?mysql_real_escape_string($_GET['\1']):false)
(isset($_POST['\1'])?mysql_real_escape_string($_POST['\1']):false)
============================
Update: Yeah, after some research I figured out that Notepad++ does not support most regular expressions. I guess one additional step can not hurt a person. It's just laziness.
*NOTE: BUT if anyone wants to try feel free to comment.
At least it is just 2 steps and not 20.
Hi!
I try to upload file, how can i check if file is upload
when i send empty input witch file upload i get
AttributeError: 'unicode' object has no attribute 'filename'
How can i check added file?
I am trying to translate the following:
Action:
pushl %ebp
movl %esp, %eax
subl $32, %esp
movl $0, -8(%eax)
movl $0, -4(%eax)
movl -4(%eax), %eax
cmpl 32(%eax), %ebp
movl -4(%ebp), %eax
sall $2, %ebp
addl 8(%ebp), %ebp
movl (%ebp), %ebp
addl %ebp, -8(%eax)
addl $1, -4(%eax)
What is the best way to learn assembly and translating this code?