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";
This line:
used_emails = [row.email for row
in db.execute(select([halo4.c.email], halo4.c.email!=''))]
Returns:
['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]']
I use this to find a match:
if recipient in used_emails:
If it finds a match I need to pull another field (halo4.c.code) from the database in the same row. Any suggestions on how to do this?
I'm trying to edit a legacy wss3 sharepoint site.
Messing around with a 700+ code lines aspx page I got a "The server tag is not well formed." error on sharepoint and The ?content=1 trick does not work.
Anyone has a tip on how to get to the line that's causing the problem?
I'm expecting something like the aspnet ysod, at least that's usefull.
If it's worth something, I have access to the actual server.
I feel a little stupid for having to ask this… But I can't seem find it documented anywhere.
If I've got a Model with FileField, how can I stuff an uploaded FILE into that FileField?
For example, I'd like to do something like this:
class MyModel(Model):
file = FileField(...)
def handle_post(request, ...):
mymodel = MyModel.objects.get(...)
if request.FILES.get("newfile"):
mymodel.file = request.FILES["newfile"]
But that doesn't appear to work.
Hi there,
I am writing a comment-stripper and trying to accommodate for all needs here. I have the below stack of code which removes pretty much all comments, but it actually goes too far. A lot of time was spent trying and testing and researching the regex patterns to match, but I don't claim that they are the best at each.
My problem is that I also have situation where I have 'PHP comments' (that aren't really comments' in standard code, or even in PHP strings, that I don't actually want to have removed.
Example:
<?php $Var = "Blah blah //this must not comment"; // this must comment. ?>
What ends up happening is that it strips out religiously, which is fine, but it leaves certain problems:
<?php $Var = "Blah blah ?>
Also:
will also cause problems, as the comment removes the rest of the line, including the ending ?
See the problem? So this is what I need...
Comment characters within '' or "" need to be ignored
PHP Comments on the same line, that use double-slashes, should remove perhaps only the comment itself, or should remove the entire php codeblock.
Here's the patterns I use at the moment, feel free to tell me if there's improvement I can make in my existing patterns? :)
$CompressedData = $OriginalData;
$CompressedData = preg_replace('!/\*.*?\*/!s', '', $CompressedData); // removes /* comments */
$CompressedData = preg_replace('!//.*?\n!', '', $CompressedData); // removes //comments
$CompressedData = preg_replace('!#.*?\n!', '', $CompressedData); // removes # comments
$CompressedData = preg_replace('/<!--(.*?)-->/', '', $CompressedData); // removes HTML comments
Any help that you can give me would be greatly appreciated! :)
here is the relevent code snippet:
public static Rand searchCount (int[] x)
{
int a ;
int b ;
int c ;
int d ;
int f ;
int g ;
int h ;
int i ;
int j ;
Rand countA = new Rand () ;
for (int l= 0; l<x.length; l++)
{
if (x[l] = 0)
a++ ;
else if (x[l] = 1)
b++ ;
}
}
return countA ;
}
(Rand is the name of the class that this method is in)
when compiling it get this error message:
Rand.java:77: illegal start of type
return countA ;
^
what's going wrong here? what does this error message mean?
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?
I need to do some additional processing after a Drupal page has been sent.
I know I could fire a background shell command, but I need the current Drupal execution context to be maintained.
I've spent a lot of time looking, but I can't find any documentation in this regard. This is surprising because it must surely be a common requirement.
The only real idea I have is to fire up Drupal (again) via a shell command (exec, etc) and supply it with a pseudo path which would invoke the continued processing. But this seems unnecessarily complex/wasteful.
Any pointers greatly appreciated, tks.
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
I am using MS AJAX ASP.NET Components (Calendar Extender) and I'm finding this problem.
Some weekdays are not being displayed....
I uploaded a picture so you can view exactly how it is being displayed...
The one on the right (calnder) in the picture is taken from microsoft's sample.
Have you got any idea what is causing this problem?
See screenshot: http://www.sajtkik.com/calendar.jpg
Thanks Alot!
Let me start by saying I have looked at many similar questions asked, but all of them relate to Timestamp and DateTime field type without indexing. At least that is my understanding.
As we all know, there are certain advantages when it comes to DateTime. Putting them aside for a minute, and assuming table's engine is InnoDB with 10+ million records, which query would perform faster when criteria is based on:
DateTime with index
int with index
In other words, it is better to store date and time as DateTime or UNIX timestamp in int? Keep in mind there is no need for any built-in MySQL functions to be used.
There's always a need to make method names as concise as possible but without getting too long and waffly.
At what point is a method name far too long to possibly be justified?
I'm parsing Xml data which has entries like this:
<item name="UserText" type_name="gh_string" type_code="10"> </item>
I'm supposed to read the 6 spaces as a String, but both the InnerText and InnerXml values of the System.Xml.XmlNode are zero length Strings.
Is there any way I can get at this whitespace data in existing files and what do I need to do in the future to prevent this sort of screw up?
what java method takes an int and returns +1 or -1? the criteria for this is weather or not the int is positive or negative. I looked through the documentation but i'm bad at reading it and i can't find it. I know i've seen it somewhere though.
If I've got a Container with a child component that is off either the top or the left hand side:
Is there any way to get scroll bars to show up? ie, so I can scroll up and get the button back in view, the same way I could if the button was off the bottom right side?
Thanks!
Ok so I am learning C++ slowly. I am familiar with all the console syntax and everything, but now I'm moving on to windows programming. Now what im trying to do, is create a DLL that I inject into a process, so it's hooked in. All I want the C++ application to do, is have text in it, that says "Hooked" if it's successfully injected, and an error if something wrong happened. Or even if I can do it without a DLL, Just open an executable, and when the certain process I'm trying to hook is opened, the status is changed to "Hooked". Also I have a safaribooksonline.com account so if there is any good reads you would recommend, just write it down. thanks
Hi,
I'm needing to build multiple environments and tag them in subversion using a nant script. Is there a way that I can use nant to create the tags in svn with a variable I supply?
Thanks.
hi
I have a page that has two dropdownlists(one for the locations, and the other for departments), an employee search textbox and a button. On the other page, I have a gridview. Now, what i want to archieve is that when a user types an employee's name in the textbox control, selects a location from the location dropdownlist, and a department from the departments dropdownlist, and click the button(search), the gridview on the other page must show the reqiured information of a SINGLE employee. Only one row must show.
I have created a database for the employees. I know how to do this with the autopostback but i have not tried it using a button's click. NB: the gridview should show only one row of a selected employee. I'm using ASP.NET VB
Your help will high apprecaited.
Someone recently asked a question about the Ghost Design Pattern - I have not seen this before.
What is the Ghost Design Pattern and how is it implemented? I can only find snippets on the web in reference to it.
This line of code:
System.out.println ("aray[j], "+aray[j]+", divided by sum, "+sum+", equals: aray[j]/sum: "+ aray[j]/sum) ;
is yeilding this line of text:
aray[j], 21, divided by sum, 100, equals: aray[j]/sum: 0
why is it doing this? (everything is right eccept that the answer should be .21)
I have a delegate that modifies an object. I pass an object to the delegate from a calling method, however the calling method does not pickup these changes. The same code works if I pass a List as the object. I thought all objects were passed by reference so any modifications would be reflected in the calling method?
I can modify my code to pass a ref object to the delegate but am wondering why this is necessary?
public class Binder
{
protected delegate int MyBinder<T>(object reader, T myObject);
public void BindIt<T>(object reader, T myObject)
{
//m_binders is a hashtable of binder objects
MyBinder<T> binder = m_binders["test"] as MyBinder<T>;
int i = binder(reader, myObject);
}
}
public class MyObjectBinder
{
public MyObjectBinder()
{
m_delegates["test"] = new MyBinder<MyObject>(BindMyObject);
}
private int BindMyObject(object reader, MyObject obj)
{
//make changes to obj in here
}
}
///calling method in some other class
public void CallingMethod()
{
MyObject obj = new MyObject();
MyBinder binder = new MyBinder();
binder.BindIt(myReader, obj); //don't worry about myReader
//obj should show reflected changes
}
Hello, sorry for answer but how to enable TCP in SQL server 2005 express edition? I used configuration manager, find network configuration/protocols and there enabled TCP, after that I have restarted sql server service and tried installation of problematic software again (software which told me that TCP is not enabled) but I have the same problem :-(
Hi,
I'm wondering how facebook extracts the right picture of the article from a link? they ignore any icons, ads images, or other not related images, & they gives you the right image?
What technique/method they use? because i've tried to extract all images using a php regex but how to find the right one?
Thanks
The "application:applicationDidFinishLaunchingWithOptions:" message does not get called when an application is sitting in the background in iOS 4, and I'm trying to figure out how to be notified when the application is brought back into the foreground by another application.
My application registers itself as a handler for certain file types, and Safari and other supported applications allow passing the files over to my app. This works great if the app is closed before I try to use it, but fails otherwise.
In my application:applicationDidFinishLaunchingWithOptions: I have:
NSURL *url = (NSURL *)[launchOptions valueForKey:UIApplicationLaunchOptionsURLKey];
if([url isFileURL]) {
}
[self.window makeKeyAndVisible];
return YES;
As stated already, this works great so far for starting the app when it's not sitting in the background - but when I switch back over to Safari or Mail and try to open a new file that is supported, my application wakes up from the background and becomes active again but I can't see any "withOptions" overrides for application:applicationWillEnterForeground: or any way to identify what was passed in when it enters the foreground.
What would be the appropriate way to receive these "open file notifications" when the application is in the background?