Has America become the land of the double standard?
Lets see: if we lie to the Congress, it's a felony and if the Congress lies to us its just politics; if we dislike a black person, we're racist and if a black person dislikes whites, its their 1st Amendment right; the government spends millions to rehabilitate criminals and they do almost nothing for the victims; in public schools you can teach that homosexuality is OK, but you better not use the word God in the process; you can kill an unborn child, but it is wrong to execute a mass murderer; we don't burn books in America, we now rewrite them; we got rid of communist and socialist threats by renaming them progressive; we are unable to close our border with Mexico, but have no problem protecting the 38th parallel in Korea; if you protest against President Obama's policies you're a terrorist, but if you burned an American flag or George Bush in effigy it was your 1st Amendment right.
You can have pornography on TV or the internet, but you better not put a nativity scene in a public park during Christmas; we have eliminated all criminals in America, they are now called sick people; we can use a human fetus for medical research, but it is wrong to use an animal.
We take money from those who work hard for it and give it to those who don't want to work; we all support the Constitution, but only when it supports our political ideology; we still have freedom of speech, but only if we are being politically correct; parenting has been replaced with Ritalin and video games; the land of opportunity is now the land of hand outs; the similarity between Hurricane Katrina and the gulf oil spill is that neither president did anything to help.
And how do we handle a major crisis today? The government appoints a committee to determine who's at fault, then threatens them, passes a law, raises our taxes; tells us the problem is solved so they can get back to their reelection campaign.
What has happened to the land of the free and home of the brave?
In the interest of full-disclosure (and a bit of bragging), my iPad should arrive early next week!
I'm dumbfounded by her attitude -- so much so that I don't really know what to say. The fact is, I'm unapologetic about not knowing how to speak in her native tongue, or any other tongue for that matter. I'm not opposed to being multilingual, but I am opposed to and take offense to a visitor to this country to expect me (or any other American) to speak their language. I don't think I need to mention the hypocrisy of the stewardess' attitude if I were to demand the same of her if the situation were reversed. Now, go back to Chile, young lady, and don't come back until you learn some manners!
Humans originally existed as members of small bands of nomadic hunters/gatherers. They lived on deer in the mountains during the summer and would go to the coast and live on fish and lobster in the winter.
The two most important events in all of history were the invention of beer and the invention of the wheel. The wheel was invented to get man to the beer. These were the foundation of modern civilization and together were the catalyst for the splitting of humanity into two distinct subgroups: liberals and conservatives.
Once beer was discovered, it required grain and that was the beginning of agriculture. Neither the glass bottle nor aluminum can were invented yet, so while our early humans were sitting around waiting for them to be invented, they just stayed close to the brewery. That's how villages were formed.
Some men spent their days tracking and killing animals to BBQ at night while they were drinking beer. This was the beginning of what is known as the conservative movement.
Other men who were weaker and less-skilled at hunting learned to live off the conservatives by showing up for the nightly BBQs and doing the sewing, fetching, and hairdressing. This was the beginning of the liberal movement.
Some of these liberal men eventually evolved into women. Those became known as girlie-men. Some noteworthy liberal achievements include the domestication of cats, the invention of group therapy, group hugs, and the concept of democratic voting to decide how to divide the meat and beer that conservatives provided.
Over the years conservatives came to be symbolized by the largest, most powerful land animal on earth, the elephant. Liberals, conversely, are symbolized by the jackass.
Modern liberals like imported beer but most prefer white wine or imported bottled water. They eat raw fish, but like their beef well done. Sushi, tofu, and French food are standard liberal fare. Another interesting evolutionary side note: most of their women have higher testosterone levels than their men. Most social workers, personal injury attorneys, journalists, dreamers in Hollywood, and group therapists are liberals. Liberals invented the designated hitter rule because it wasn't fair to make the pitcher also bat.
Conservatives drink domestic beer, mostly Bud Lite, Bud, or Miller. They eat red meat and still provide for their women. Conservatives are big-game hunters, rodeo cowboys, lumberjacks, construction workers, firemen, medical doctors, police officers, engineers, corporate executives, athletes, members of the military, airline pilots, and generally anyone who works productively. Conservatives who own companies hire other conservatives who want to work for a living.
Liberals produce little or nothing. They like to govern the producers and decide what to do with the production. Liberals believe Europeans are more enlightened than Americans. That is why most of the liberals remained in Europe when conservatives were coming to America. They crept in after the Wild West was tamed and created a business of trying to get more for nothing.
End of lesson.
It was shutdown 1,132 (or so) days prior to move it from its original server room to the new datacenter.The Helper Functions
The first task was to create a function to calculate the decimal (BIGINT) equivalent of a properly formatted IPv4 address. PostgreSQL's INET and CIDR datatypes are ideal for this because of the address validation they provide (which makes life significantly easier).
CREATE OR REPLACE FUNCTION inet_to_longip(v_t INET)
RETURNS BIGINT AS /*{{{*/
$inet_to_longip$
DECLARE
t TEXT[];
i BIGINT;
BEGIN
t := REGEXP_SPLIT_TO_ARRAY(HOST(v_t), E'\\.');
i := (t[1]::BIGINT << 24) + (t[2]::BIGINT << 16) +
(t[3]::BIGINT << 8) + t[4]::BIGINT;
RETURN i;
END;
$inet_to_longip$ LANGUAGE plpgsql STRICT IMMUTABLE; /*}}}*/
Once we can obtain the decimal (BIGINT) version of the IP address, we need to be able to return it to an INET or CIDR datatype. I couldn't find in the documentation where each of the two datatypes was simply a string, but that's what I discovered as I naively concatenated all the numbers and dots into one. In the interest of full disclosure, I found the basis of this function on the obsolete Wiki of an apparently defunct Linux firewall project that stored the rules in a PostgreSQL v7.4 database.
CREATE OR REPLACE FUNCTION longip_to_inet(v_i BIGINT)
RETURNS INET AS /*{{{*/
$longip_to_inet$
DECLARE
t INET;
BEGIN
t = ((v_i >> 24) & 255::BIGINT) || '.' ||
((v_i >> 16) & 255::BIGINT) || '.' ||
((v_i >> 8) & 255::BIGINT) || '.' ||
(v_i & 255::BIGINT);
RETURN t;
END;
$longip_to_inet$ LANGUAGE plpgsql STRICT IMMUTABLE; /*}}}*/
The last required piece is a function to determine the most significant bit of what will become the new netmask in the resultant properly-aligned network.
CREATE OR REPLACE FUNCTION netmask_msb(v_i BIGINT)
RETURNS INTEGER AS /*{{{*/
$netmask_msb$
DECLARE
n INTEGER;
BEGIN
FOR n IN REVERSE 31 .. 1 LOOP
IF (v_i & (1 << n)) > 0 THEN
RETURN n;
END IF;
END LOOP;
RETURN n;
END;
$netmask_msb$ LANGUAGE plpgsql STRICT IMMUTABLE; /*}}}*/
A Bonus Function
As an added bonus, I decided to write a quick function to determine the natural class of the network. Years ago, there was no such thing as CIDR, and this was as granular (with classes A, B, and C, anyway) as a block of IP addresses could be.
CREATE OR REPLACE FUNCTION natural_class(v_t INET)
RETURNS CHAR AS /*{{{*/
$natural_class$
DECLARE
o1 BIGINT := inet_to_longip(v_t) >> 28;
BEGIN
CASE
WHEN o1 >> 3 = 0 THEN RETURN('A');
WHEN o1 >> 2 = 2 THEN RETURN('B');
WHEN o1 >> 1 = 6 THEN RETURN('C');
WHEN o1 = 14 THEN RETURN('D');
WHEN o1 = 15 THEN RETURN('E');
END CASE;
RETURN NULL;
END;
$natural_class$ LANGUAGE plpgsql STRICT IMMUTABLE; /*}}}*/
Now that we have the ability to convert the addresses in both directions and do some minor bit-banging to determine what the new netmask should be, let's put it all together. For my purposes, all I needed was the new network and netmask in dotted-quad format. Below, you'll find a few more pieces of information that may or may not be of interest. I can definitely see a use for outputting the data in binary format.
CREATE OR REPLACE FUNCTION align( /*{{{*/
IN v_t1 INET, IN v_t2 INET,
OUT oldstart INET, OUT oldend INET, OUT oldhosts INTEGER,
OUT newstart INET, OUT newend INET, OUT newhosts INTEGER,
OUT cidrmask INT, OUT dqmask INET) RETURNS RECORD AS
$align$
DECLARE
v_oldstart INET := HOST(v_t1);
v_oldend INET := HOST(v_t2);
--
v_oldstart_long BIGINT := inet_to_longip(v_oldstart);
v_oldend_long BIGINT := inet_to_longip(v_oldend);
ipmask BIGINT := v_oldstart_long # v_oldend_long;
maskmsb INTEGER := netmask_msb(ipmask);
new_ipmask BIGINT := (1 << (maskmsb + 1)) - 1;
v_newstart_long BIGINT := v_oldstart_long & ~new_ipmask;
v_newend_long BIGINT := v_oldend_long | new_ipmask;
v_newstart INET := longip_to_inet(v_newstart_long);
v_newend INET := longip_to_inet(v_newend_long);
v_newnet INET :=SET_MASKLEN(v_newstart::cidr,
32 - (maskmsb + 1));
BEGIN
if (v_t1 > v_t2) THEN
RAISE EXCEPTION
'Starting address must be lower than ending address';
END IF;
oldstart := v_oldstart;
oldend := v_oldend;
oldhosts := v_t2 - v_t1 + 1;
newstart := v_newstart;
newend := v_newend;
newhosts := v_newend - v_newstart + 1;
cidrmask := MASKLEN(v_newnet);
dqmask := NETMASK(v_newnet);
RETURN;
END;
$align$ LANGUAGE plpgsql STRICT IMMUTABLE; /*}}}*/
Next Step(s)
There are probably a few inefficiencies in the code I've presented in this tutorial of sorts. I'll leave finding and fixing them (and the binary output) as an exercise for the reader. Admittedly, some of the functionality could be made easier by creating casts to go between the two data formats.
Conclusion
That's all there is to it. Now, when you're trying to configure a VPN device that will be installed at a remote location and all the information you have is information from the receptionist via voicemail (e.g. "Our allowable numbers from the internet people are sixty-six point eighty-eight point one hundred and two point thirty-three to sixty-six point eighty-eight point one hundred and two point thirty-seven), you have access to enough information to mostly configure it before you ship it ahead of your trip to wherever that device may be going (hopefully someplace warm).
Let me know what you think.
sqlplus / as sysdba
create pfile='/var/tmp/pfile.txt' from spfile;
Edit /var/tmp/pfile.txt, add parameter(s):
*.nls_date_format='YYYY-MM-DD'
shutdown immediate
startup pfile='/var/tmp/pfile.txt'
Ensure change is effected (e.g. select sysdate from dual;)
create spfile from pfile='/var/tmp/pfile.txt';
shutdown immediate
startup
Enter Python. For many years, I've heard and read that people rave about the benefits of Python, but was never interested because of its strong ties to OOP. Now that I have seen firsthand how the OOP model can significantly increase the software design and implementation process (because it's more aligned with the way we naturally think), I thought I'd see if Python could fit comfortably between Perl and Java.
I began simply by directly translating my Perl dnscat script to Python (i.e. keeping the procedural logic the same, just changing it to Python syntax). The direct translation was going quickly and quite well as I began, and I quickly located the parts of the API applicable to the task. It was all going well, that is, until I reached the regular expression searches on CNAME and A records. My forward progress has ceased, and I cannot see how Python can be nearly as powerful as Perl.
To be continued -- maybe...

Recent Comments