I want to convert a tab delimited text file to a XML file. I was able to do it with a single character delimiter. But how do i extend it to tabs? I am coding in C# and using Visual Studio 2010.
Example:
Suppose in the following example I want to match strings that do not contain the word "NOOOT".
Example A: This shirt is NOOOT black.
Example B: This shirt is black.
I want something a little bit like the like the non-matching character class (e.g. [^abc]), but for whole strings:
.*?(^NOOOT).*?
Does such a creature exist?
Hello,
Does adding a Web Service to my ASP.NET MVC project break the whole concept of MVC?
That Web Service (WCF) depends on the Model layer from my MVC project to communicate with the back-end (so it looks to me like it needs to be part of the MVC solution).
Should I add this to the Controller or Model layer?
I have a WPF textbox, and perform the following actions
Enter text as "12345"
Move cursor between 3 and 4 (using arrow or
mouseclick)
Enter 0 (so Text is now "123045")
Which event/eventargs can tell me that 0 was typed at location 4.
I need to know this at Preview level so that I can reject the character 0 based on the prefixed and suffixed digits.
I have a batch file that I want to improve. Instead of requiring a user to provide a folder path without a trailing slash, is there an easy way for me to just remove the last character from the path if there is a slash on the end?
:START
@echo What folder do you want to process? (Provide a path without a closing backslash)
set /p datapath=
::Is string empty?
IF X%datapath% == X GOTO:START
::Does string have a trailing slash?
IF %datapath:~-1%==\ GOTO:START
Hi, I'm working on a hash function which gets a string as input.
Right now I'm doing a loop and inside the hash (an int variable) is being multiplied by a value and then the ASCII code for the current character is added to the mix.
hash = hash * seed + string[i]
But sometimes, if the string is big enough there is an integer overflow there, what can I do to avoid it while maintaining the same hash structure? Maybe a bit operation included inside the loop?
Hi,
I need huffman code(best in python or in java), which could encode text not by one character (a = 10, b = 11), but by two (ab = 11, ag = 10). Is it possible and if yes, where could i find it, maybe it's somewhere in the internet and i just can'd find it?
When I start editing a UITextField, I have the "Clear When Editing Begins" option checked so it starts off with no text. However, the "Return" button is grayed out until you type at least one character.
I've seen other iphone apps where the "Return" button is not grayed out (and if you press it with no text, then it goes back to what the text used to be). How is this done?
Thanks.
In various bits of Android code I've seen:
public class MyActivity extends Activity {
public void method() {
mContext = this; // since Activity extends Context
mContext = getApplicationContext();
mContext = getBaseContext();
}
}
However I can't find any decent explanation of which is preferable, and under what circumstances which should be used.
Pointers to documentation on this, and guidance about what might break if the wrong one is chosen, would be much appreciated.
So, simply I want to be able to run a for across a list of URLs, if one fails then I want to continue on to try the next.
I've tried using the following but sadly it throws and exception if the first URL doesn't work.
servers = ('http://www.google.com', 'http://www.stackoverflow.com')
for server in servers:
try:
u = urllib2.urlopen(server)
except urllib2.URLError:
continue
else:
break
else:
raise
Any ideas?
Thanks in advance.
In textmate, when there's a current selection, I hit the " key and the selection gets surrounded by quotes. The same thing happens with other balanced characters like (, {, [ and '.
Am I missing something obvious in Emacs configuration that would enable similar behaviour when using transient mark mode, or do I need to break out elisp and write something?
I have a form text field that I want to allow only numbers and letters in. (i.e., no #$!, etc...) Is there a way to throw up an error and prevent the keypress from actually outputting anything if the user tries to use any character other than numbers and letters? I've been trying to find a plugin, but haven't really found anything that does this...
I am playing with the unix hexdump utility. My input file is UTF-8 encoded, containing a single character ñ, which is C3 B1 in hexadecimal UTF-8.
hexdump test.txt
0000000 b1c3
0000002
Huh? This shows B1 C3 - the inverse of what I expected! Can someone explain?
For getting the expected output I do:
hexdump -C test.txt
00000000 c3 b1 |..|
00000002
I was thinking I understand encoding systems..
How can I have each of these a elements break on to new lines, but keeping them as display=inline and without br tags?
<div>
<a href="element1">Element 1</a>
<a href="element1">Element 2</a>
<a href="element1">Element 3</a>
</div>
In Java, the hash code for a String object is computed as
s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
using int arithmetic, where s[i] is the ith character of the string, n is the length of the string, and ^ indicates exponentiation.
Why is 31 used as a multiplier?
I understand that the multiplier should be a relatively large prime number. So why not 29, or 37, or even 97?
The rule at work here is that users can be awarded badges for a streak of 10, 20, and 30. If the user has a streak over 30, such as 40 or 50, then the logic must be that it only awards a 10-streak badge for 40 and a 20-streak badge for 50, and so on.
def check_win_streak(streak)
badge = 10
while badge < badge::MAX_STREAK_BADGE_SIZE do # MAX_STREAK_BADGE_SIZE = 30
if streak < badge then
break
end
if (streak % badge == 0) then
award_streak_badge(badge)
end
badge += 10
end
end
Hi ,
I am finding Email ids in mu project, where I am preprocessing the input using some Regular Expression.
RegExpPhone6.RegComp("[\[\{\(][ -]?[s][h][i][f][t][ -]?[+-][2][ -]?[\]\}\)]");
Here while I am compiling i am getting a warning msg like
Warning 39 warning C4129: ')' : unrecognized character escape sequence
How can i resolve this ?
Why this is occuring and Where will it affect?
Kindly help me...
Im using Rails, Passenger (both are 3.0.5) and Nginx on my production server. As I heard, Rails should show public/404.html or public/500.html instead of development errors like ActiveRecord::RecordNotFound or Unknown action but that doesn't happen. I've tried to delete config.ru file and set rack_env or rails_env in nginx.conf but nothing helped.
Here is my nginx.conf:
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /home/makk/.rvm/gems/ruby-1.9.2-p0/gems/passenger-3.0.5;
passenger_ruby /home/makk/.rvm/bin/passenger_ruby;
#passenger_ruby /home/makk/.rvm/wrappers/ruby-1.9.2-p0/ruby;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /home/makk/projects/1server/deploy/current/public;
index index.html index.htm;
passenger_enabled on;
rack_env production;
recursive_error_pages on;
if (-f /home/makk/projects/1server/maintenance.html) {
return 503;
}
error_page 404 /404.html;
error_page 500 502 504 /500.html;
error_page 503 @503;
}
location @503 {
error_page 405 = /maintenance.html;
# Serve static assets if found.
if (-f $request_filename) {
break;
}
rewrite ^(.*)$ /maintenance.html break;
}
location ~ ^(\/phpmyadmin\/)(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(\/phpmyadmin\/)(.*)$;
fastcgi_param SCRIPT_FILENAME /usr/share/phpmyadmin/$fastcgi_path_info;
include fastcgi_params;
}
}
}
It seems that this question duplicates this one but there are no working suggestions.
UPD: I have both development and production apps on same PC. In production Rails ignores config.consider_all_requests_local = false (in /config/environments/production.rb) due to local_request? method. So one of possible solutions is listed below (taken from here):
# config/initializers/local_request_override.rb
module CustomRescue
def local_request?
return false if Rails.env.production? || Rails.env.staging?
super
end
end
ActionController::Base.class_eval do
include CustomRescue
end
Or for Rails 3:
class ActionDispatch::Request
def local?
false
end
end
Hi,
I am dealing with developing and Application for European Client and they have their native character set.
Now I need to have regex which would allow foreign characters like eéèêë etc and am not sure of how this can be done.
Any Suggestions ?
I notice that the character/symbol '`' and '@' is not used as an operator in C/C++,
does anyone know the reason or historically why its so?
if its really not used, is it safe to define those symbols as another operator/statement using #define?
I wanted to take character array from console and it also include white spaces, the only method i know in C is scanf, but it miss stop taking input once it hit with white space. What i should do?
Here is what i am doing.
char address[100];
scanf("%s", address);
Have done quite a bit of searching for a guide (of any substance) for the above to no avail. Can anyone refer me to one?
In the present tense however, I am trying to understand the below code example, which returns a two digit representation of the month, that corresponds to the 3 character month name set in v:
SET v=May
SET map=Jan-01;Feb-02;Mar-03;Apr-04;May-05;Jun-06;Jul-07;Aug-08;Sep-09;Oct-10;Nov-11;Dec-12
CALL SET v=%%map:*%v%-=%%
SET v=%v:;=&rem.%
ECHO.%v%
I'm trying to fade an element in and out, but with a slight pause in between, it works without the pause, but when I add the pause using the jQuery delay()-function, it just stops;
Here's the code:
$('#headerimage2').each(function(){
for(i=1;i<50;i++){
$(this).fadeOut(1200).delay(1000).fadeIn(1000).delay(1000);
}
});
Why does the delay()-function (both first and second) break the loop?
What debugging tools are available for directshow filters? Presently, I have a project that compiles and registers a video source filter that I then setup a graph in GraphEdit. I am using c++ in visual studio 2008. Is it possible to get a debugger attached to the filter in any way where I could set break points, inspect variables, etc? Barring that is there a way to log diagnostic information somewhere that I can view in real time?