A page for randomness

January 30, 2008

You could do what?

Filed under: funny, quotes — Mark @ 11:54 am

Suresh: “Ok, I’m seriously going.”

Mark: “What? You’re seriously gay?”

Suresh: “I could make you gay.”

Inline functions

Filed under: personal, programming — Mark @ 10:06 am

What’s the deal with inline functions?

When the compiler inline-expands a function call, the function’s code gets inserted into the caller’s code stream (conceptually similar to what happens with a #define macro). This can, depending on a zillion other things, improve performance, because the optimizer can procedurally integrate the called code — optimize the called code into the caller.

There are several ways to designate that a function is inline, some of which involve the inline keyword, others do not. No matter how you designate a function as inline, it is a request that the compiler is allowed to ignore: it might inline-expand some, all, or none of the calls to an inline function. (Don’t get discouraged if that seems hopelessly vague. The flexibility of the above is actually a huge advantage: it lets the compiler treat large functions differently from small ones, plus it lets the compiler generate code that is easy to debug if you select the right compiler options.)

Source

January 29, 2008

Why We Need Obama: Obama is the Democrats’ Reagan

Filed under: personal, political — Mark @ 3:11 pm

Why We Need Obama: Obama is the Democrats’ Reagan
Here is a great article from a conservative Republican commentator on Beliefnet. This echoes what we Obama supporters have been saying for months. He thinks Obama will “win in a landslide” if he wins the Democratic nomination:

If I were a Republican, I’d be very, very afraid. Oh wait, I am a Republican. Dang. Lord have mercy, I wish that man were a conservative. Because there’s no doubt in my mind about what he can accomplish for liberalism if he’s elected. You’ve heard of Reagan Democrats? Barack Obama is the Democrats’ Reagan.

January 28, 2008

The Thriving Cult of Greed and Power

Filed under: news, religious — Mark @ 12:03 am
By all appearances, Noah Lottick of Kingston, Pa., had been a normal, happy 24-year-old who was looking for his place in the world. On the day last June when his parents drove to New York City to claim his body, they were nearly catatonic with grief. The young Russian-studies scholar had jumped from a 10th-floor window of the Milford Plaza Hotel and bounced off the hood of a stretch limousine. When the police arrived, his fingers were still clutching $171 in cash, virtually the only money he hadn’t yet turned over to the Church of Scientology, the self-help “philosophy” group he had discovered just seven months earlier.

His death inspired his father Edward, a physician, to start his own investigation of the church. “We thought Scientology was something like Dale Carnegie,” Lottick says. “I now believe it’s a school for psychopaths. Their so-called therapies are manipulations. They take the best and brightest people and destroy them.” The Lotticks want to sue the church for contributing to their son’s death, but the prospect has them frightened. For nearly 40 years, the big business of Scientology has shielded itself exquisitely behind the First Amendment as well as a battery of high-priced criminal lawyers and shady private detectives.

The Church of Scientology, started by science-fiction writer L. Ron Hubbard to “clear” people of unhappiness, portrays itself as a religion. In reality the church is a hugely profitable global racket that survives by intimidating members and critics in a Mafia-like manner. At times during the past decade, prosecutions against Scientology seemed to be curbing its menace. Eleven top Scientologists, including Hubbard’s wife, were sent to prison in the early 1980s for infiltrating, burglarizing and wiretapping more than 100 private and government agencies in attempts to block their investigations. In recent years hundreds of longtime Scientology adherents — many charging that they were mentally or physically abused — have quit the church and criticized it at their own risk. Some have sued the church and won; others have settled for amounts in excess of $500,000. In various cases judges have labeled the church “schizophrenic and paranoid” and “corrupt, sinister and dangerous.”

Source

January 27, 2008

Ted Kennedy endorsing Obama

Filed under: news, political — Mark @ 11:58 pm
Senator Edward M. Kennedy will endorse Barack Obama for president tomorrow, breaking his year-long neutrality to send a powerful signal of where the legendary Massachusetts Democrat sees the party going — and who he thinks is best to lead it.

Kennedy confidantes told the Globe today that the Bay State’s senior senator will appear with Obama and Kennedy’s niece, Caroline Kennedy, at a morning rally at American University in Washington tomorrow to announce his support.

That will be a potentially significant boost for Obama as he heads into a series of critical primaries on Super Tuesday, Feb. 5.

Kennedy believes Obama can “transcend race” and bring unity to the country, a Kennedy associate told the Globe. Kennedy was also impressed by Obama’s deep involvement last year in the bipartisan effort to craft legislation on immigration reform, a politically touchy subject the other presidential candidates avoided, the associate said.

The coveted endorsement is a huge blow to New York Senator Hillary Clinton, who is both a senatorial colleague and a friend of the Kennedy family. In a campaign where Clinton has trumpeted her experience over Obama’s call for hope and change, the endorsement by one of the most experienced and respected Democrats in the Senate is a particularly dramatic coup for Obama.

Source

Operating Thetan

Filed under: religious, wikipedia — Mark @ 11:47 pm
Scientology doctrine states that a person who has achieved the state of Operating Thetan is essentially a being able to operate free of the encumbrances of the material universe. This state is represented by a symbol consisting of the letters OT with the T inside the O and each of the points of the T ending at the O’s circumference.The secrets of attaining the Operating Thetan states are taught in a series of courses called “levels”, numbered with Roman numerals and starting at OT I. Operating Thetan levels up to OT VIII have been released by the Church of Scientology. Hubbard claimed to have written OT levels up to OT XV.

After having removed one’s own reactive mind and thus attaining the state of Clear, one may then go on to the levels above OT III which were later replaced by New Era Dianetics for OTs. L. Ron Hubbard wrote on September 15, 1978: “There is a special handling for OTs who have been run on Dianetics since Clear. It is called ‘NED for OTs’.”

The Fishman Affidavit contains much text from the old versions of the Operating Thetan levels. The versions of OT I to OT VII in the Fishman Affidavit are considered authentic as the Church of Scientology has brought copyright lawsuits over their release on the Internet.

Note that the claimed OT VIII in Fishman, which refers to Jesus as “a lover of young men and boys”, is not considered authentic — not only has the Church stated it is inauthentic and not brought suit over it, but ex-members who reached OT VIII have come forward and concurred. The Church claimed it as a copyright violation in the suit against Arnaldo Lerma, but later said this was an error. Fishman stated that he had obtained his copy of OT VIII from a different source than his copies of the other OT Levels, purchased from a fellow Scientologist.

Operating Thetan - Wikipedia, the free encyclopedia

The E-meter

Filed under: religious, wikipedia — Mark @ 11:38 pm
An E-meter is an electronic device manufactured by the Church of Scientology at their Gold Base production facility. It is used as an aid by Dianetics and Scientology counselors and counselors-in-training in some forms of auditing, the application of the techniques of Dianetics and Scientology to another or to oneself for the express purpose of addressing spiritual issues. The device is formally known as the Hubbard Electrometer.

A 1971 ruling of the United States District Court, District of Columbia (333 F. Supp. 357), specifically stated, “The E-meter has no proven usefulness in the diagnosis, treatment or prevention of any disease, nor is it medically or scientifically capable of improving any bodily function.”

The E-meter measures changes in the electrical resistance of the human body by inducing a tiny electrical current through the body. The device’s primary component is an electrical measuring instrument called a Wheatstone bridge, functioning much like a galvanometer, that indicates changes in the subject’s resistance. According to Scientology doctrine, the resistance corresponds to the “mental mass and energy” of the subject’s mind, which change when the subject thinks of particular mental images (engrams). These concepts have no recognition among scientists outside of Scientology; the action of the E-meter is more commonly attributed to galvanic skin response, an effect used in polygraph tests.

E-meter sessions are conducted by church employees known as auditors. Scientology materials traditionally refer to the subject as the “preclear”, although auditors continue to use the meter well beyond the clear level. The preclear holds a pair of cylindrical electrodes (”cans”) connected to the meter while the auditor asks the preclear a series of questions and notes both the verbal response and the activity of the meter. Auditor training describes many types of needle movements, with each having their own special significance.

The meter has two control dials. The larger dial, known as the “tone arm”, adjusts the meter bias, while the smaller one controls the gain. Auditors manipulate the tone arm during an auditing session to keep the E-meter needle on a marked reference point.

E-meter - Wikipedia, the free encyclopedia

Scientology Awards Show Video Tom Cruise

Filed under: religious — Mark @ 11:33 pm

Scientology-Awards-Show-Video—Tom-Cruise - Get Video Code

Scientology Awards Show Video Tom Cruise - Putfile.com

January 25, 2008

LSMSA Alumni Database

Filed under: geek, news, personal, programming — Mark @ 6:19 pm

Well as GK has informed me, the new alumni database for LSMSA stores their passwords in plaintext. He found out from an error when updating his profile information and could actually see the SQL query. So I decided to go check the site out and see if I could do any SQL injection. I ended up screwing my profile page over, so now I can’t update anything. I also managed to get a few more injections to work, but I wasn’t able to see GK’s password because of how the query was structured. However, that doesn’t mean this site is secure.

After learning this information, I’ve changed my password to something pretty random, so that I won’t be the victim of some exploit.

DeadJournal Posts Imported (August 2003 - February 2004)

Filed under: personal — Mark @ 6:15 pm

I’ve imported some old DeadJournal postings from the following months: August 2003 - February 2004

January 23, 2008

The Radical Path to Purity

Filed under: personal, religious — Mark @ 11:44 am

Suppose I said, “There’s a great-looking girl down the street. Let’s go look through her window and watch her undress, then pose for us naked, from the waist up. Then this girl and her boyfriend will get in a car and have sex – let’s listen and watch the windows steam up!”

You’d be shocked. You’d think, What a pervert!

But suppose instead I said, “Hey, come on over. Let’s watch Titanic.”

Christians recommend this movie, church youth groups view it together, and many have shown it in their homes. Yet the movie contains precisely the scenes I described.

So, as our young men lust after bare breasts on the screen, our young women are trained in how to get a man’s attention.

How does something shocking and shameful somehow become acceptable because we watch it through a television instead of a window?

In terms of the lasting effects on our minds and morals, what’s the difference?

Yet many think, Titanic? Wonderful! It wasn’t even rated R!

Every day Christians across the country, including many church leaders, watch people undress through the window of television. We peek on people committing fornication and adultery, which our God calls an abomination.

We’ve become voyeurs, Peeping Toms, entertained by sin.

Normalizing evil
The enemy’s strategy is to normalize evil. Consider young people struggling with homosexual temptation. How does it affect them when they watch popular television dramas where homosexual partners live together in apparent normality?

Parents who wouldn’t dream of letting a dirty-minded adult baby-sit their children do it every time they let their kids surf the channels. Not only we, but our children become desensitized to immorality. Why are we surprised when our son gets a girl pregnant if we’ve allowed him to watch hundreds of immoral acts and hear thousands of jokes with sexual innuendos?

But it’s just one little sex scene.

Suppose I offered you a cookie, saying, “A few mouse droppings fell in the batter, but for the most part it’s a great cookie –you won’t even notice.”

“To fear the LORD is to hate evil” (Proverbs 8:13). When we’re being entertained by evil, how can we hate it? How can we be pure when we amuse ourselves with impurity?

God warns us not to talk about sex inappropriately:
“But among you there must not be even a hint of sexual immorality, or of any kind of impurity… because these are improper for God’s holy people. Nor should there be obscenity, foolish talk or coarse joking, which are out of place” (Ephesians 5:3-4).

How do our favorite dramas and sitcoms stand up to these verses? How about Seinfeld and other nightly reruns? Do they contain “even a hint of sexual immorality” or “coarse joking”? If we can listen to late night comedians’ monologues riddled with immoral references, are we really fearing God and hating evil?

Jesus, the radical
Consider Christ’s words:

“You have heard that it was said, ‘Do not commit adultery.’ But I tell you that anyone who looks at a woman lustfully has already committed adultery with her in his heart. If your right eye causes you to sin, gouge it out and throw it away. It is better for you to lose one part of your body than for your whole body to be thrown into hell. And if your right hand causes you to sin, cut it off and throw it away. It is better for you to lose one part of your body than for your whole body to go into hell” (Matthew 5:27-30).
Why does Jesus paint this shocking picture? I believe He wants us to take radical steps, to do whatever is necessary to deal with sexual temptation.

Now, the hand and eye are not the causes of sin. A blind man can still lust and a man without a hand can still steal. But the eye is a means of access for both godly and ungodly input. And the hand is a means of performing righteous or sinful acts. We must therefore govern what the eye looks at and the hand does.

If we take Jesus seriously, we need to think far more radically about sexual purity.

Doing what it takes
The battle is too intense, and the stakes are too high to approach purity casually or gradually.
So … if you can’t keep your eyes away from those explicit images, don’t ever go to a video rental store. Come on. Everybody goes into those stores.

No. If it causes you to sin, you shouldn’t. Period.

Do your thoughts trip you up when you’re with certain persons? Stop hanging out with them. Does a certain kind of music charge you up erotically? Stop listening to it. Do you make phone calls you shouldn’t? Block 900 phone sex numbers so you can’t call them from your home.

If these things seem like crutches, fine. Use whatever crutches you need to help you walk.

Some men fall into mental adultery through lingerie ads, billboards, women joggers in tight pants, women with low cut blouses or short skirts, cheerleaders or dancers, movies, TV shows, and commercials of the beer-and-bikini variety. Some men’s weakness is the Sunday newspaper’s ad inserts or nearly any magazine.

So, stop looking. And then stop putting yourself in the position to look!

If you have to get rid of your TV to guard your purity, do it.

If it means you can’t go to games because of how dancers or cheerleaders dress and perform, so be it. If it means you have to lower your head and close your eyes, so be it. If you’re embarrassed to do that, stay home.

Tell your wife about your struggles. Or if you’re single, tell a godly friend. If you need to drop the newspaper because of those ads, fine. If you need your wife to go through it first and pull out the offending inserts, ask her.

Romans 13:14 instructs us to “make no provision for the flesh” (NASB). It’s a sin to deliberately put ourselves in a position where we’ll likely commit sin. Whether it’s the lingerie department, the swimming pool, or the workout room at an athletic club, if it trips you up, stay away from it.

Proverbs describes the loose woman meeting up with the foolish man after dark (see Proverbs 7:8-9). We must stay away from people, places, and contexts that make sin more likely.

If it’s certain bookstores or hangouts, stay away from them. If cable or satellite TV or network TV, old friends from high school, the Internet, or computers are your problem, get rid of them.

Just say no to whatever is pulling you away from Jesus. Remember, if you want a different outcome, you must make different choices.

If you can’t be around women wearing swimsuits without looking and lusting, then don’t go on vacation where women wear swimsuits. If that means not going water-skiing or to a favorite resort, fine. If it means being unable to go on a church-sponsored retreat, don’t go.

Sound drastic? Compare it to gouging out an eye or cutting off a hand!

“But…”
But there are hardly any decent TV shows anymore. Then stop watching TV. Read books. Have conversations.

But all the newer novels have sex scenes. Then read the old novels. Read fiction from Christian publishers.

But I’ve subscribed to Sports Illustrated for thirty years, back before they had the swimsuit issue. They have it now. So drop your subscription. And tell them why.

But it’s almost impossible to rent a movie without sex and offensive language. There are Christian movie review sites that can help you make good selections for family viewing. There are also services which offer edited movies, television adaptors which edit profanity, and DVD software that cuts offensive scenes from movies.

But suppose there were no decent movies – what then? I enjoy good movies, but the Bible never commands us, “Watch movies.” It does command us, “Guard your heart.”

It’s a battle – battles get bloody. Do whatever it takes to walk in purity!

A friend wrote a daily contract that asks these questions: “Are you willing to do whatever’s necessary to protect your sexual sobriety? Ask God for help? Call on others? Go to meetings? Read literature? Set boundaries and not cross them? Be brutally honest?”

Too radical?
But you’re talking about withdrawing from the culture. What you’re saying is too radical.

No, what I’m saying is nothing. Jesus said, “If it would keep you from sexual temptation, you’d be better off poking out your eye and cutting off your hand.” Now that’s radical.

Many claim they’re serious about purity, but then they say, “No way; I’m not going to give up cable TV,” or “I’m not going to have my wife hold the computer password.”

Followers of Jesus have endured torture and given their lives in obedience to Him. And we’re whining about giving up cable?

When Jesus called us to take up our crosses and follow Him (see Matthew 10:38), didn’t that imply sacrifices greater than forgoing Internet access?

How sold out are you to the battle for purity? How desperate are you to have victory over sin? How radical are you willing to get for your Lord? How much do you want the joy and peace that can be found only in Him? Purity comes only to those who truly want it.

Controlling the Internet
• Use family-friendly Internet service providers. Install a pornography-filtering program on your computer, realizing it can’t screen out everything. Ask someone else to hold the password. Ask someone to regularly check your Internet usage history.
• Use family-friendly Internet service providers. Install a pornography-filtering program on your computer, realizing it can’t screen out everything. Ask someone else to hold the password. Ask someone to regularly check your Internet usage history.
• Move computers to high-traffic areas. Unless you have a proven history of going on-line safely, don’t log on to the Internet if you’re alone. Be sure the monitor always faces an open door, where others can see what you’re looking at (1 Corinthians 10:13).
• If you’re still losing the battle, disconnect the Internet — or get rid of the computer.

Taking charge of the TV
• Consult a schedule to choose appropriate programs. Channel-surfing invites temptation.
• Keep your television unplugged, store it in a closet, or put it in the garage to prevent mindless flip-on.
• Use the “off” switch freely. Use the remote quickly when temptation comes. Have a safe channel ready to turn to.
• Don’t allow young children to choose their own programs. As they get older they can choose, but parents have veto power. Avoid multiple TVs that split the family and leave children unsupervised. Don’t use television as a babysitter.
• Spend an hour reading Scripture, a Christian book, or participating in a ministry for each hour you watch TV. Even when television isn’t bad, it often keeps us from what’s better.
• Drop cable, HBO, your satellite dish, or your TV if it is promoting ungodliness in your home. (This isn’t legalism — it’s discipleship.)
• Periodically “fast” from television for a week or a month. Watch what happens; see if you like what you can do with all that time (including feeding your passion for Christ).
AFAJournal.org - Randy Alcorn

10 Stephen Hawking Quotes

Filed under: funny, quotes — Mark @ 10:42 am
10. “Einstein was wrong when he said “God does not play dice”. Consideration of black holes suggests, not only that God does play dice, but that He sometimes confuses us by throwing them where they can’t be seen.”

9. “I have noticed even people who claim everything is predestined, and that we can do nothing to change it, look before they cross the road.”

8. “My goal is simple. It is a complete understanding of the universe, why it is as it is and why it exists at all.”

7. “I find that American & Scandinavian accents work better with women.” In response to a question about the American accent of his synthesiser.

6. “Someone told me that each equation I included in the book would halve the sales. In the end, however, I did put in one equation, Einstein’s famous equation, E = mc2. I hope that this will not scare off half of my potential readers.”

5. “My expectations were reduced to zero when I was 21. Everything since then has been a bonus.”

4. “To show this diagram properly, I would really need a four dimensional screen. However, because of government cuts, we could manage to provide only a two dimensional screen.”

3. “Life would be tragic if it weren’t funny.”

2. “The whole history of science has been the gradual realization that events do not happen in an arbitrary manner, but that they reflect a certain underlying order, which may or may not be divinely inspired.”

1. “Eternity is a very long time, especially towards the end.”

Stephen Hawking’s Quotations - The Land Salmon

First day of classes

Filed under: personal, undergrad computer science classes — Mark @ 10:29 am

Well on to my last semester, doesn’t look like it is going to be terribly interesting.

My first class, math455 a.k.a. “numerical analysis”, was a yawn. For one thing, I realized how much I had forgot of Calculus, but then I pretty much remembered it all again, due in part to the teacher’s painstakingly slow walkthrough over fundamental theorems of Calculus. She’s this older Chinese lady and kept saying things like “too hard?”, “too fast?”, “any questions?”, but of course in that not-native English speaking accent. Also, the class is in a room full of old computers..with, of course, windows. Ugh.

My next class, cmps455 a.k.a. “operating systems”, was also pretty boring. I found myself getting pretty sleepy, except for the part when I got angry because blake was asking all kinds of dumb questions again…and it’s the first day. Give it a break.

Other than that, the day was pretty much inconsequential, but I did go to wild wings and had some beer, so that was probably the highlight of the day.

My name isn’t dumb…

Filed under: funny, quotes — Mark @ 10:18 am

“Sounds like Batman, Superman, and Golconda”

January 21, 2008

Why Linux will not displace Windows

You are kidding arent you?

re you saying that this linux can run on a computer without windows underneath it, at all ? As in, without a boot disk, without any drivers, and without any services ?

That sounds preposterous to me.

If it were true (and I doubt it), then companies would be selling computers without a windows. This clearly is not happening, so there must be some error in your calculations. I hope you realise that windows is more than just Office ? Its a whole system that runs the computer from start to finish, and that is a very difficult thing to acheive. A lot of people dont realise this.

Microsoft just spent $9 billion and many years to create Vista, so it does not sound reasonable that some new alternative could just snap into existence overnight like that. It would take billions of dollars and a massive effort to achieve. IBM tried, and spent a huge amount of money developing OS/2 but could never keep up with Windows. Apple tried to create their own system for years, but finally gave up recently and moved to Intel and Microsoft.

Its just not possible that a freeware like the Linux could be extended to the point where it runs the entire computer fron start to finish, without using some of the more critical parts of windows. Not possible.

I think you need to re-examine your assumptions.
Posted by: jerryleecooper Posted on: 03/14/07

Source

January 18, 2008

Russia Goes Linux

Filed under: computers and technology, linux, unix, and open source, news — Mark @ 11:04 pm

LinuxHow2 | Russia Goes Linux

Due to the rampant pirating of Windows within the Russian education system, Russia decided it was time to move towards the open source operating system, Linux, in order to prevent further pirating. Armada Group of Companies (RTS, MICEX: ARMD) claims to have completed the first stage of the project to provide the Russian educational institutions with the Linux operating system. It should save the Russians millions. But what about TCO (the Total Cost of Ownership) for Linux? Aren’t all the Microsoft reports true that Linux’s TCO is much higher than that of Windows? If that’s the case, it doesn’t seem to be affecting countries all over the world and their switch to Linux for schools.

“We plan to launch the distributives in pilot schools in February and would like directors and teachers from all Russian regions not to wait till 2009 but start implementing OSS just now”, said Alexey Kuzovkin, Armada director general, “The necessary information will be published on the project site linux.armd.ru one of these days.” The conversion to OSS tools in Russian schools is going to be a speedy process.

The open source software tools are developed to be extremely efficient and capable of running on the cheapest of hardware. A lot of the Russian schools computers are equipped with only 128 mb of RAM, and the OSS tools were designed with this in mind. Within 2008 the company has to provide no less than 50% of city and 20% of rural schools with OSS in three Russian regions: the Republic of Tatarstan, Perm Territory and Tomsk Region.

Who else is doing this?

Russia isn’t the first nation to look at the open source operating system as an alternative in the classroom. Back in 2006, School districts in India made the plunge and dropped Microsoft Windows in favor of Linux. In 2005, some Italian schools switched from proprietary software to the open source variety. Last year, the Nigerian government opted to go with Linux for its schools (see a previous news item here on that topic). And, believe it or not, even several states in the U.S. have seen a number of their school districts switching to or incorporating Linux in their learning environment, such as Indiana (20,000 students and growing in 2006).
But Linux can’t be all it claims to be, right?

So, what’s the deal? Why isn’t TCO scaring these school districts to sticking with Windows? Well, maybe it’s because TCO is a bunch of ***insert expletive here***, and the world is gradually waking up to this reality. The Linux operating system is open source, and therefore, you can get it for free. The software is open source, and therefore, you can get it for free. Linux was built from the ground up to be server-based, so it’s extremely easy to install PCs as thin clients, hooked up to one central server, which does all of the work of housing the software; this means that an IT professional need only worry about installing and upgrading individual software tools on one machine. These days, the learning grade is minimal; several distributions have done such a good job of creating GUI tools for system administration (such as Fedora, openSUSE, and Ubuntu) that one hardly ever needs to know the underpinnings of the system to administer upgrades, create users, and set up networks. TCO is garbage; it’s FUD, and no one should believe what Microsoft says anyway. Who honestly believes that Linux costs more than Windows? The only people I know of fool hardy enough to trick themselves into thinking so are Microsoft IT professionals too afraid to consider some competition in the market.

Arguing with a believer is like playing chess..

Filed under: funny, personal, religious — Mark @ 10:59 pm

arguing_with_a_believer_is_like_chess.png

069.png (PNG Image, 700×300 pixels)

fgets - C++ Reference

Filed under: random, science — Mark @ 5:47 pm

fgets - C++ Reference
char * fgets ( char * str, int num, FILE * stream );

<cstdio>

Get string from stream

Reads characters from stream and stores them as a C string into str until (num-1) characters have been read or either a newline or a the End-of-File is reached, whichever comes first.
A newline character makes fgets stop reading, but it is considered a valid character and therefore it is included in the string copied to str.
A null character is automatically appended in str after the characters read to signal the end of the C string.

Parameters

str
Pointer to an array of chars where the string read is stored.
num
Maximum number of characters to be read (including the final null-character). Usually, the length of the array passed as str is used.
stream
Pointer to a FILE object that identifies the stream where characters are read from.
To read from the standard input, stdin can be used for this parameter.

Return Value
On success, the function returns the same str parameter.
If the End-of-File is encountered and no characters have been read, the contents of str remain unchanged and a null pointer is returned.
If an error occurs, a null pointer is returned.
Use either ferror or feof to check whether an error happened or the End-of-File was reached.

sscanf - C++ Reference

Filed under: personal, programming — Mark @ 5:43 pm

sscanf - C++ Reference

int sscanf ( char * str, const char * format, …);

<cstdio>

Read formatted data from string

Reads data from str and stores them according to the parameter format into the locations given by the additional arguments. Locations pointed by each additional argument are filled with their corresponding type of value specified in the format string.

Parameters

str

C string that the function processes as its source to retrieve the data.

format

C format string that contains formatting control characters.

SNPRINTF - formatted output to a string.

Filed under: personal, programming — Mark @ 4:35 pm

SNPRINTF - formatted output to a string.

(ANSI Standard)
Usage:

#include <stdio.h>
i = snprintf( s, N, control [, arg1, arg2, ...] );

Where:

char *s;
is the string to which the output should be written.

size_t N;
specifies the maximum number of characters that can be written to “s” (including a ‘\0′ to mark the end of the string). If N is zero, the “s” pointer may be null.

const char *control;
is a “printf” control string.

arg1, arg2, …
are the values to be output.

int i;
is the number of characters that would have been output if N was sufficiently large to permit the entire string. This count does not include the ‘\0′ used to mark the end of the string. If a write error occurs, a negative number is returned.

FILE Object

Filed under: personal, programming — Mark @ 4:34 pm

Source

Object containing information to control a stream

This type of object identifies a stream and contains the information needed to control it, including a pointer to its buffer, its position indicator and all its state indicators.

FILE objects are usually created by a call to either fopen or tmpfile, which both return a reference to one of these objects.
The content of a FILE object is not meant to be read from outside the functions of the cstdio library; In fact, its main purpose is to be referenced as an argument in all stream-involving functions of this library to identify the stream to be affected.
Its memory allocation is automatically performed by either fopen or tmpfile, and is the responsibility of the library to free the resources once the stream has been closed using fclose or other means.
On inclusion of the cstdio header file, three objects of type FILE * (pointer to FILE)are automatically created. These are associated with the standard input, output and error streams, and can be accessed respectivelly through the pointers stdin, stdout and stderr.

CACS Christmas tree finally put away

Filed under: funny, personal, quotes — Mark @ 10:40 am

Today the CACS Christmas tree, which has been up since early December, has finally been put away.

Christmas is officially over.

- Dr. Radle

Ten good UNIX usage habits

1. Make directory trees in a single swipe.
2. Change the path; do not move the archive.
3. Combine your commands with control operators.
4. Quote variables with caution.
5. Use escape sequences to manage long input.
6. Group your commands together in a list.
7. Use xargs outside of find.
8. Know when grep should do the counting — and when it should step aside.
9. Match certain fields in output, not just lines.
10. Stop piping cats.


1. Make directory trees in a single swipe

Bad:

~ $ mkdir tmp
~ $ cd tmp
~/tmp $ mkdir a
~/tmp $ cd a
~/tmp/a $ mkdir b
~/tmp/a $ cd b
~/tmp/a/b/ $ mkdir c
~/tmp/a/b/ $ cd c
~/tmp/a/b/c $

Good:

~ $ mkdir -p tmp/a/b/c

Better:

~ $ mkdir -p \
project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat/a}


2. Change the path; do not move the archive

Use the -C option to change the extract directory:

~ $ tar xvf -C tmp/a/b/c newarc.tar.gz


3. Combine your commands with control operators

Run a command only if another command returns a zero exit status:

~ $ cd tmp/a/b/c && tar xvf ~/archive.tar

Run a command only if another command returns a non-zero exit status:

~ $ cd tmp/a/b/c || mkdir -p tmp/a/b/c

You can also combine the control operators. Each works on the last command run.


4. Quote variables with caution.

~ $ ls tmp/
a b
~ $ VAR=”tmp/*”
~ $ echo $VAR
tmp/a tmp/b
~ $ echo “$VAR”
tmp/*
~ $ echo $VARa
~ $ echo “$VARa”
~ $ echo “${VAR}a”
tmp/*a
~ $ echo ${VAR}a
tmp/a
~ $


5. Use escape sequences to manage long input

~ $ cd tmp/a/b/c || \
> mkdir -p tmp/a/b/c && \
> tar xvf -C tmp/a/b/c ~/archive.tar


6. Group your commands together in a list

Run a list of commands in a subshell:

~ $ ( cd tmp/a/b/c/ || mkdir -p tmp/a/b/c && \
> VAR=$PWD; cd ~; tar xvf -C $VAR archive.tar ) \
> | mailx admin -S “Archive contents”

Run a list of commands in the current shell:

~ $ { cp ${VAR}a . && chown -R guest.guest a && \
> tar cvf newarchive.tar a; } | mailx admin -S “New archive”


7. Use xargs outside of find

~/tmp $ ls -1 | xargs
December_Report.pdf README a archive.tar mkdirhier.sh
~/tmp $ ls -1 | xargs file
December_Report.pdf: PDF document, version 1.3
README: ASCII text
a: directory
archive.tar: POSIX tar archive
mkdirhier.sh: Bourne shell script text executable
~/tmp $

The xargs command is useful for more than passing file names. Use it any time you need to filter text into a single line.

Be cautious using xargs:
Technically, a rare situation occurs in which you could get into trouble using xargs. By default, the end-of-file string is an underscore (_); if that character is sent as a single input argument, everything after it is ignored. As a precaution against this, use the -e flag, which, without arguments, turns off the end-of-file string completely.


8. Know when grep should do the counting — and when it should step aside

~ $ time grep and tmp/a/longfile.txt | wc -l
2811
real 0m0.097s
user 0m0.006s
sys 0m0.032s

~ $ time grep -c and tmp/a/longfile.txt
2811
real 0m0.013s
user 0m0.006s
sys 0m0.005s
~ $


9. Match certain fields in output, not just lines

A tool like awk is preferable to grep when you want to match the pattern in only a specific field in the lines of output and not just anywhere in the lines.

Bad:

~/tmp $ ls -l /tmp/a/b/c | grep Dec
-rw-r–r– 7 joe joe 12043 Jan 27 20:36 December_Report.pdf
-rw-r–r– 1 root root 238 Dec 03 08:19 README
-rw-r–r– 3 joe joe 5096 Dec 14 14:26 archive.tar
~/tmp $

Good:

~/tmp $ ls -l | awk ‘$6 == “Dec”‘
-rw-r–r– 3 joe joe 5096 Dec 14 14:26 archive.tar
-rw-r–r– 1 root root 238 Dec 03 08:19 README
~/tmp $


10. Stop piping cats

A basic-but-common grep usage error involves piping the output of cat to grep to search the contents of a single file. This is absolutely unnecessary and a waste of time, because tools such as grep take file names as arguments. You simply do not need to use cat in this situation at all.

~ $ time cat tmp/a/longfile.txt | grep and
2811
real 0m0.015s
user 0m0.003s
sys 0m0.013s

~ $ time grep and tmp/a/longfile.txt
2811
real 0m0.010s
user 0m0.006s
sys 0m0.004s
~ $

source

The radical view

Filed under: political, quotes, religious — Mark @ 9:39 am
The radical view is to say that we’re going to change the definition of marriage so that it can mean two men, two women, a man and three women, a man and a child, a man and animal.

- Mike Huckabee, Republican presidential hopeful, defending his view of marriage
source

January 17, 2008

DeadJournal Posts Imported (May 2003, June 2003, July 2003)

Filed under: personal — Mark @ 8:06 pm

I’ve imported some old DeadJournal postings from the following months:

May 2003

June 2003

July 2003 

Dj Project - Before I Sleep

Filed under: music, personal, youtube — Mark @ 8:01 pm

Favorite song #2 of the week:

www.dj-project.ro

Muse - Knights of Cydonia

Filed under: music, personal, youtube — Mark @ 7:59 pm

Favorite song #1 of the week:

Why does AT&T want to know what you’re downloading?

Filed under: computers and technology, news — Mark @ 6:22 pm
Chances are that as you read this article, it is passing over part of AT&T’s network. That matters, because last week AT&T announced that it is seriously considering plans to examine all the traffic it carries for potential violations of U.S. intellectual property laws. The prospect of AT&T, already accused of spying on our telephone calls, now scanning every e-mail and download for outlawed content is way too totalitarian for my tastes. But the bizarre twist is that the proposal is such a bad idea that it would be not just a disservice to the public but probably a disaster for AT&T itself. If I were a shareholder, I’d want to know one thing: Has AT&T, after 122 years in business, simply lost its mind?No one knows exactly what AT&T is proposing to build. But if the company means what it says, we’re looking at the beginnings of a private police state. That may sound like hyperbole, but what else do you call a system designed to monitor millions of people’s Internet consumption? That’s not just Orwellian; that’s Orwell.

The puzzle is how AT&T thinks that its proposal is anything other than corporate seppuku. First, should these proposals be adopted, my heart goes out to AT&T’s customer relations staff. Exactly what counts as copyright infringement can be a tough question for a Supreme Court justice, let alone whatever program AT&T writes to detect copyright infringement. Inevitably, AT&T will block legitimate materials (say, home videos it mistakes for Hollywood) and let some piracy through. Its filters will also inescapably degrade network performance. The filter AT&T will really need will be the one that blocks the giant flood of complaints and termination-of-service notices coming its way.

But the most serious problems for AT&T may be legal. Since the beginnings of the phone system, carriers have always wanted to avoid liability for what happens on their lines, be it a bank robbery or someone’s divorce. Hence the grand bargain of common carriage: The Bell company carried all conversations equally, and in exchange bore no liability for what people used the phone for. Fair deal.

AT&T’s new strategy reverses that position and exposes it to so much potential liability that adopting it would arguably violate AT&T’s fiduciary duty to its shareholders. Today, in its daily Internet operations, AT&T is shielded by a federal law that provides a powerful immunity to copyright infringement. The Bells know the law well: They wrote and pushed it through Congress in 1998, collectively spending six years and millions of dollars in lobbying fees to make sure there would be no liability for “Transitory Digital Network Communications”—content AT&T carries over the Internet. And that’s why the recording industry sued Napster and Grokster, not AT&T or Verizon, when the great music wars began in the early 2000s.

Here’s the kicker: To maintain that immunity, AT&T must transmit data “without selection of the material by the service provider” and “without modification of its content.” Once AT&T gets in the business of picking and choosing what content travels over its network, while the law is not entirely clear, it runs a serious risk of losing its all-important immunity. An Internet provider voluntarily giving up copyright immunity is like an astronaut on the moon taking off his space suit. As the world’s largest gatekeeper, AT&T would immediately become the world’s largest target for copyright infringement lawsuits.

source

January 15, 2008

100% pro-…

Filed under: religious — Mark @ 12:02 pm
I am 100% pro-life, unless we’re talking about capital punishment, in which case I am 100% pro-death.

source

Getting ready for the Rapture

Filed under: religious — Mark @ 11:52 am
A few months ago I felt led to put together a “post rapture file” for my unsaved loved ones which is on my computer. My daughter knows that if she doesn’t come to Christ before we go that she is to get this file and share it with everyone. I’m working on a list of names and contact info to put in the file. Anyway, today I just felt very strongly that not only should I remind her of it, but to witness to her for the 1000th time and give her complete instructions on what to do as soon as we are gone. I even went so far as to tell her as soon as we are gone that she is to go to a house that belongs to a friend since he will be gone too. It is WAY off the grid. I’m going to talk to him about it tomorrow and get directions. He loves Tiffany like his own granddaughter so I know it will be fine since all of his loved ones are going too.

I gave her the pin # to my atm and credit cards. I told her to make sure that she plants as big a garden as she can and learn to can food. Not to worry about the kids because they will be with Nana. I’m putting instructions in the file about how to start the generator, where her Daddy’s guns are and how to load them, where the spare car and truck keys are, etc., etc., etc.

source

Newer Posts »

Powered by WordPress