|
I want to make such firewall or want to hook into some process to do that.
I have downloaded NetDefender and Easy Firewall and few others. But after adding rules, none of them was able to block.
I also tried "Block All" option of NetDefender application. But it could not block.
Every time I receive a message something like "Could not register rule with network adapter". I am the administrator so there should not be any problem with permissions but I don't know why it is not working.
|
|
|
|
|
|
From the first string I need to build the second string, I know it can be done reiteratively but I'm wondering if there is a cute method of achieving this.
From this
"/100/101/201/"
I need to create this string - note the pipe delimiter.
"/100/|/100/101/|/100/101/201/"
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Define Cute?
You could split it, convert to integers, apply some lickety-split maths, reconvert to a string and concatenate.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Dunno if it's cute but I'd do a string.split and double-loop over the resulting array.
If the "records" are always fixed to 3 digits long you can do something like:
public string Foo(string original)
{
string output = original;
string remainder = outputstring.RemoveLastFourCharacters();
while (remainder.Length > 0)
{
output = remainder + "|" + output;
remainder = remainder.RemoveLastFourCharacters();
}
return output;
}
Obviously RemoveLastFourCharacters doesn't exist, I'd add a RemoveEndCharacters(int numberOfCharacters) type method or extension method. The other thing to consider is a StringBuilder , but only if the original string is likely to be long.
|
|
|
|
|
My mistake - # characters, it is basically a heirarchy id as a string. JAAN got the cutest result.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Bah! I did not haz TeH Codez!
|
|
|
|
|
I wouldn't call it cute, but it is clear:
string source = "/100/101/201/";
string resultWanted = "/100/|/100/101/|/100/101/201/";
string[] items = source.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
StringBuilder item = new StringBuilder("/");
StringBuilder sb = new StringBuilder();
string separator = "";
foreach (string s in items)
{
item.Append(s);
item.Append("/");
sb.Append(separator + item);
separator = "|";
}
if (sb.ToString() == resultWanted)
{
MessageBox.Show("OK");
}
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
That was the method I basically was going to use, JAANs one is decidedly cute and I may even learn something from it.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: I may even learn something from it.
Like "Don't use Linq operator except to make yourself indispensable"?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
string actual = "/100/101/201/";
var result = actual.ToCharArray()
.Select((x, y) => new { ch = x, pos = y })
.Where(x => x.ch == '/' && x.pos > 0)
.Select(x => actual.Substring(0, x.pos + 1))
.ToArray();
string derived = String.Join("|", result);
Console.WriteLine(derived);
Is this cute?
"Never put off until run time what you can do at compile time."
- David Gries, in "Compiler Construction for Digital Computers", circa 1969.
|
|
|
|
|
And the winner is - thats about as cute as they get and yest obfuscated it certainly is.
Thakn you for the codez
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: the winner
"Never put off until run time what you can do at compile time."
- David Gries, in "Compiler Construction for Digital Computers", circa 1969.
|
|
|
|
|
Cute? Yep!
Works? Yep!
Easily understood? Nope!
Gets a 5 from me anyway
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Thanks.
"Never put off until run time what you can do at compile time."
- David Gries, in "Compiler Construction for Digital Computers", circa 1969.
|
|
|
|
|
Note, you got 5 for readability, I had no trouble understanding your one but it does not make me indensible
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I knew I was doing something wrong!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Cute == obfuscated?
One method to divide them, one to combine them again
I are Troll
|
|
|
|
|
Eddy Vluggen wrote: Cute == obfuscated?
You are absolutely right, I'll now spend the next 2 hours trying to work out what JAANs has done.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Eddy Vluggen wrote: One method to divide them, one to combine them again
For some reason that reminded me of this: Ash nazg durbatulûk, ash nazg gimbatul, ash nazg thrakatulûk agh burzum-ishi krimpatul.
|
|
|
|
|
..and somehow, for some obscure reason, that reminded me of marriage
I are Troll
|
|
|
|
|
And, once we take into account your signature, we wind up with the Orc of the Covenant.
|
|
|
|
|
You should have saved that as a Friday Programming Quiz.
This ought to be more efficient than that Linq abomination:
public static string
Repeater
(
string Source
,
char Delimiter1
,
char Delimiter2
)
{
System.Text.StringBuilder result = new System.Text.StringBuilder() ;
int off = 0 ;
while ( ( off = Source.IndexOf ( Delimiter1 , off + 1 ) ) > -1 )
{
for ( int i = 0 ; i <= off ; i++ ) result.Append ( Source [ i ] ) ;
result.Append ( Delimiter2 ) ;
}
return ( result.ToString ( 0 , result.Length - 1 ) ) ;
}
|
|
|
|
|
PIEBALDconsult wrote: Friday Programming Quiz
Not a chance, one of these codz will turn up in my app this morning (with an appropriate link to the author of course).
PIEBALDconsult wrote: return ( result.ToString ( 0 , result.Length - 1 ) )
I didn't realise you could manage the lenght during a tostring() operation.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: I didn't realise you could manage the lenght during a tostring() operation.
Lots of people don't; I think I learned it in the last year.
|
|
|
|