|
My missus is a good rower. She can row better than most. She will row with anyone. She's always rowing - shes never been near a boat though.
|
|
|
|
|
Movie Quote Of The Day
And so our compulsory education was coming to an end.
Which movie?
|
|
|
|
|
Paris does biology
if(this.signature != "")
{
MessageBox.Show("This is my signature: " + Environment.NewLine + signature);
}
else
{
MessageBox.Show("404-Signature not found");
}
|
|
|
|
|
How to Train Your Dragon?
You have just been Sharapova'd.
|
|
|
|
|
|
|
Debbie in High School
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
A Clockwork Orange
Geek code v 3.12
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- r++>+++ y+++*
Weapons extension: ma- k++ F+2 X
I use 1TBS
|
|
|
|
|
Do you visit the Korova Milk Bar often?
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
If software development were a circus, we would all be the clowns.
|
|
|
|
|
I have a bed in its backroom
Geek code v 3.12
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- r++>+++ y+++*
Weapons extension: ma- k++ F+2 X
I use 1TBS
|
|
|
|
|
Nothing better than a good glass of milk
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
If software development were a circus, we would all be the clowns.
|
|
|
|
|
|
Evil!
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
That's what the system is like - not my idea
But since my time in school they have made it 13 years
|
|
|
|
|
Fast Times at Ridgemont High
Mongo: Mongo only pawn... in game of life.
|
|
|
|
|
stefto's school life in a nutshell <-- nominated for a oscar apparently
Life's like a nose, you've got to get out of it whats in it!
|
|
|
|
|
The other day, in the course of my job, I was presented with the following challenge.
Given an IP address (IPv4 or IPv6) and the "number of set leading bits of the subnet mask", generate the actual subnet mask.
For example, given an IPv4 address and the value 16 , produce 255.255.0.0 .
There are thirty-three such subnet masks for IPv4 and one hundred twenty-nine for IPv6.
I, of course, created a look-up table (in a database) rather than generating the mask each time, but I still had to write the code to do it (so I did).
Your challenge, should you choose to accept it, is to do likewise in a language of your choice, or at least describe a technique.
|
|
|
|
|
Hardcode it in a library of course !
|
|
|
|
|
Wow. That's hard. On my old computer I would have set up two 16 bit registers to hold the result and a counter, initialized with 32. As long as the counter is <= the length of the mask, I would (over both registers) bitwise shift in a 1, otherwise a 0. Loop ends when 32 shifts have been done.
Expanding this to IPv6 would require a third register (luckily the CPU has 16 of them) and the counter would have to be initialized to 48, otherwise everything remains the same.
The machine code for this would be about 20 - 30 bytes long, even if this is an ancient 8 bit CPU. Back then this problem would have been a basic (no pun intended) exercise.
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
If software development were a circus, we would all be the clowns.
|
|
|
|
|
CDP1802 wrote: The machine code for this would be about 20 - 30 bytes long
And in the modern way of doing things, this is how far that gets you.. Ah well, that's progress!
[Test]
public voi
How do you know so much about swallows? Well, you have to know these things when you're a king, you know.
modified 31-Aug-21 21:01pm.
|
|
|
|
|
Except for the shift instruction with carry, I would still know all instructions and could do it right now. The bosses would probably not see the importance, so it may have to wait.
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
If software development were a circus, we would all be the clowns.
|
|
|
|
|
I'm 100% sure that the best method would be starting the windows settings programmatically and then send messages to the right buttons and IP controls to set it to automatically calculate the right value, then just copy the result in a memory variable, it's up to you to close the open windows again...
Of course you should implement that thinking in all Windows versions.
Easy, fast, always correct and working with only a little help of the Spy++ tool.
PS: I think today it will be a great programming day...
Have a nice weekend!
|
|
|
|
|
Just to make sure i'm understanding everything right.
You want to convert CIDR notation to dotted decimal?!
My approach is to convert the CIDR to a binary string (eg. /8 = 11111111000000000000000000000000), then split this string to the octets in an array (eg. [0]=11111111 [1]=00000000 [2]=00000000 [3]=00000000) and then converting each octet to decimal.
Sample source in C#:
public enum IP_TYPE
{
IPv4
, IPv6
}
public String convertCIDR2DottedDecimal(int nCIDR, IP_TYPE eType)
{
int nBits = (eType == IP_TYPE.IPv4) ? 32 : 128;
String sBinary = "";
for(int nIdx = nCIDR - 1; nIdx >= 0; nIdx--)
sBinary += "1";
for(int nIdx = nBits - nCIDR; nIdx >= 0; nIdx--)
sBinary += "0";
int nOctets = (eType == IP_TYPE.IPv4) ? 4 : 16;
String[] aOctets = new String[nOctets];
for(int nIdx = 0; nIdx < nOctets; nIdx++)
{
String sOctet = "";
for(int nOctetIdx = 0; nOctetIdx < 8; nOctetIdx++)
{
sOctet += sBinary[nOctetIdx];
}
sBinary = sBinary.Substring(8);
aOctets[nIdx] = "" + Convert.ToInt32(aOctets[nIdx], 2);
}
return String.Join(".", aOctets);
}
modified 10-Apr-15 17:27pm.
|
|
|
|
|
I've built one for IPv4 in C#. I was working on IPv6, but then I got stuck because .NET doesn't have UInt128, and couldn't be bothered anymore to look for alternatives .
string subnetMaskIPv4(int bits)
{
uint max = 4294967295;
uint mask = max << (32 - bits);
byte[] maskBytes = BitConverter.GetBytes(mask);
Array.Reverse(maskBytes);
return String.Join(".", maskBytes);
}
The quick red ProgramFOX jumps right over the Lazy<Dog> .
|
|
|
|
|
42
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|