ٹیگ آرکائیو: میں Geek

سرمانا یا نیند کے بعد خالی سکرین?

ٹھیک ہے, مختصر جواب, زیادہ آپ کی جسمانی میموری کی سائز سے کرنے کے لئے اپنے مجازی میموری میں اضافہ.

طویل ورژن اب. حال ہی میں, میں نے اس کے اشتاء یا نیند موڈ سے مناسب طریقے سے اٹھنا نہیں ہو گا کہ میرے پی سی کے ساتھ یہ مسئلہ تھا. پی سی خود پر اور تیزی سے بہہ جائے گا, لیکن سکرین موڈ بجلی کی بچت کرنے کے لئے سوئچ گے, خالی رہ. اس نقطہ پر کرنے کے لئے صرف ایک ہی چیز کمپیوٹر دوبارہ شروع ہو گا.

میں ہوں کہ اچھا netizen طرح, میں نے ایک حل کے لئے انٹرنیٹ trawled کی. لیکن کسی بھی نہیں مل سکا. کچھ BIOS کی اپ گریڈنگ کی تجویز پیش کی, تو گرافکس کارڈ اور جگہ. پھر میں نے یہ ایک لینکس گروپ میں ذکر کیا دیکھا, سویپ فائل کے سائز جسمانی میموری کے مقابلے میں زیادہ ہونا چاہئے کہہ رہے ہیں کہ, اور میری ونڈوز XP مشین پر اس کی کوشش کرنے کا فیصلہ کیا. اور یہ مسئلہ حل!

تو جاگنی کے بعد خالی سکرین کے اس مسئلے کا حل آپ کے نظام میں میموری سے زیادہ کچھ مجازی میموری کے سائز مقرر کرنے کے لئے ہے. آپ کو مزید معلومات کی ضرورت ہے تو, یہاں ہے کہ کس طرح, قدم بہ قدم کی شکل میں. یہ ہدایات ایک ونڈوز XP مشین پر لاگو.

  1. پر دایاں کلک کریں “میرا کمپیوٹر” اور ہٹ “پراپرٹیز.”
  2. رام سائز پر ایک نظر ڈالیں, اور پر کلک کریں “اعلی درجے کی” ٹیب.
  3. پر کلک کریں “ترتیب” کے تحت بٹن “کارکردگی” گروپ باکس.
  4. میں “کارکردگی کے اختیارات” آتا ہے کہ ونڈو, منتخب کریں “اعلی درجے کی” ٹیب.
  5. میں “مجازی میموری” نیچے کے قریب گروپ باکس, پر کلک کریں “تبدیلی” بٹن.
  6. میں “مجازی میموری” ٹمٹمانے والے ونڈو, مقرر “اپنی مرضی کے سائز” آپ کے RAM کے سائز کے مقابلے میں زیادہ کچھ کرنے کے لئے (آپ قدم میں نے دیکھا کہ 2). تم ہے کہ کسی بھی ہارڈ ڈسک کی پارٹیشن پر مقرر کر سکتے ہیں, لیکن آپ کو ان تمام ہدایات کے ذریعے جا رہے ہیں تو, امکانات ہیں آپ صرف ہیں “C:”. میرے معاملے میں, میں نے اس پر ڈال کرنے کے لئے انتخاب کیا ہے “M:”.

آبجیکٹ کا جادو زبانیں اورینٹڈ

Nowhere is the dominance of paradigms more obvious than in object oriented languages. Just take a look at the words that we use to describe some their features: polymorphism, inheritance, virtual, abstract, overloading — all of them normal (or near-normal) everyday words, but signifying notions and concepts quite far from their literal meaning. اس کے باوجود, and here is the rub, their meaning in the computing context seems exquisitely appropriate. Is it a sign that we have taken these paradigms too far? شاید. سب کے بعد, the “object” in object oriented programming is already an abstract paradigm, having nothing to do with “That Obscure Object of Desire,” مثال کے طور پر.

We do see the abstraction process running a bit wild in design patterns. When a pattern calls itself a visitor or a factory, it takes a geekily forgiving heart to grant the poetic license silently usurped. Design patterns, despite the liberties they take with our sensitivities, add enormous power to object oriented programming, which is already very powerful, with all the built in features like polymorphism, inheritance, overloading etc.

To someone with an exclusive background in sequential programming, all these features of object oriented languages may seem like pure magic. But most of the features are really extensions or variations on their sequential programming equivalents. A class is merely a structure, and can even be declared as such in C . When you add a method in a class, you can imagine that the compiler is secretly adding a global function with an extra argument (the reference to the object) and a unique identifier (کا کہنا ہے کہ, a hash value of the class name). Polymorphic functions also can be implemented by adding a hash value of the function signature to the function names, and putting them in the global scope.

The real value of the object oriented methodology is that it encourages good design. But good programming discipline goes beyond mere adaptation of an object oriented language, which is why my first C teacher said, “You can write bad Fortran in C if you really want. Just that you have to work a little harder to do it.”

For all their magical powers, the object oriented programming languages all suffer from some common weaknesses. One of their major disadvantages is, حقیقت میں, one of the basic design features of object oriented programming. Objects are memory locations containing data as laid down by the programmer (and the computer). Memory locations remember the state of the object — by design. What state an object is in determines what it does when a method is invoked. So object oriented approach is inherently stateful, if we can agree on what “state” means in the object oriented context.

But in a user interface, where we do not have much control over the sequence in which various steps are executed, we might get erroneous results in stateful programming depending on what step gets executed at a what point in time. Such considerations are especially important when we work with parallel computers in complex situations. One desirable property in such cases is that the functions return a number solely based on their arguments. This property, termed “طہارت,” is the basic design goal of most functional languages, although their architects will concede that most of them are not strictly “pure.”

طبقوں

سب وے paradigms کے

Paradigms permeate almost all aspects of computing. Some of these paradigms are natural. مثال کے طور پر, it is natural to talk about an image or a song when we actually mean a JPEG or an MP3 file. File is already an abstraction evolved in the file-folder paradigm popularized in Windows systems. The underlying objects or streams are again abstractions for patterns of ones and zeros, which represent voltage levels in transistors, or spin states on a magnetic disk. There is an endless hierarchy of paradigms. Like the proverbial turtles that confounded Bertrand Russell (or was it Samuel Johnson?), it is paradigms all the way down.

Some paradigms have faded into the background although the terminology evolved from them lingers. The original paradigm for computer networks (and of the Internet) was a mesh of interconnections residing in the sky above. This view is more or less replaced by the World Wide Web residing on the ground at our level. But we still use the original paradigm whenever we say “ڈاؤن لوڈ، اتارنا” یا “upload.” The World Wide Web, راہ کی طرف سے, is represented by the acronym WWW that figures in the name of all web sites. It is an acronym with the dubious distinction of being about the only one that takes us longer to say than what it stands for. لیکن, getting back to our topic, paradigms are powerful and useful means to guide our interactions with unfamiliar systems and environments, especially in computers, which are strange and complicated beasts to begin with.

A basic computer processor is deceptively simple. It is a string of gates. A gate is a switch (کم یا زیادہ) made up of a small group of transistors. ایک 32 bit processor has 32 switches in an array. Each switch can be either off representing a zero, or on (one). And a processor can do only one function — add the contents of another array of gates (called a register) to itself. دوسرے الفاظ میں, it can only “accumulate.”

In writing this last sentence, I have already started a process of abstraction. I wrote “contents,” thinking of the register as a container holding numbers. It is the power of multiple levels of abstraction, each of which is simple and obvious, but building on whatever comes before it, that makes a computer enormously powerful.

We can see abstractions, followed by the modularization of the abstracted concept, in every aspect of computing, both hardware and software. Groups of transistors become arrays of gates, and then processors, registers, cache or memory. Accumulations (additions) become all arithmetic operations, string manipulations, user interfaces, image and video editing and so on.

Another feature of computing that aids in the seemingly endless march of the Moore’s Law (which states that computers will double in their power every 18 ماہ) is that each advance seems to fuel further advances, generating an explosive growth. The first compiler, مثال کے طور پر, was written in the primitive assembler level language. The second one was written using the first one and so on. Even in hardware development, one generation of computers become the tools in designing the next generation, stoking a seemingly inexorable cycle of development.

While this positive feedback in hardware and software is a good thing, the explosive nature of growth may take us in wrong directions, much like the strong grown in the credit market led to the banking collapses of 2008. Many computing experts now wonder whether the object oriented technology has been overplayed.

طبقوں

zeros اور ہیں

Computers are notorious for their infuriatingly literal obedience. I am sure anyone who has ever worked with a computer has come across the lack of empathy on its part — it follows our instructions to the dot, yet ends up accomplishing something altogether different from what we intend. We have all been bitten in the rear end by this literal adherence to logic at the expense of commonsense. We can attribute at least some of the blame to our lack of understanding (ہاں, literal and complete understanding) of the paradigms used in computing.

Rich in paradigms, the field of computing has a strong influence in the way we think and view the world. تم مجھ پر یقین نہیں ہے تو, just look at the way we learn things these days. Do we learn anything now, or do we merely learn how to access information through browsing and searching? Even our arithmetic abilities have eroded along with the advent of calculators and spreadsheets. I remember the legends of great minds like Enrico Fermi, who estimated the power output of the first nuclear blast by floating a few pieces of scrap paper, and like Richard Feynman, who beat an abacus expert by doing binomial expansion. I wonder if the Fermis and Feynmans of our age would be able to pull those stunts without pulling out their pocket calculators.

Procedural programming, through its unwarranted reuse of mathematical symbols and patterns, has shaped the way we interact with our computers. The paradigm that has evolved is distinctly unmathematical. Functional programming represents a counter attack, a campaign to win our minds back from the damaging influences of the mathematical monstrosities of procedural languages. The success of this battle may depend more on might and momentum rather than truth and beauty. In our neck of the woods, this statement translates to a simple question: Can we find enough developers who can do functional programming? Or is it cheaper and more efficient to stick to procedural and object oriented methodologies?

طبقوں

پی ایچ پی میں ایک مقامی فائل میں ایک تار کو بچانے کے لئے کس طرح?

This post is the second one in my geek series.

While programming my Theme Tweaker, I came across this problem. I had a string on my server in my php program (the tweaked stylesheet, حقیقت میں), and I wanted to give the user the option of saving it to a file his computer. I would’ve thought this was a common problem, and all common problems can be solved by Googling. لیکن, lo and behold, I just couldn’t find a satisfactory solution. I found my own, and thought I would share it here, for the benefit of all the future Googlers yet to come and go.

Before we go into the solution, let’s understand what the problem is. The problem is in the division of labor between two computers — one is the server, where your WordPress and PHP are running; the other is the client’s computer where the viewing is taking place. The string we are talking about is on the server. We want to save it in a file on the client’s computer. The only way to do it is by serving the string as an html reply.

پہلی نظر میں, this doesn’t look like a major problem. سب کے بعد, servers regularly send strings and data to clients — that’s how we see anything on the the browser, including what you are reading. If it was just any PHP program that wants to save the string, it wouldn’t be a problem. You could just dump the string into a file on the server and serve the file.

But what do you do if you don’t want to give the whole world a way of dumping strings to files on your server? ٹھیک ہے, you could do something like this:

<?php
header('Content-Disposition: attachment; filename="style.css"');
header("Content-Transfer-Encoding: ascii");
header('Expires: 0');
header('Pragma: no-cache');
print $stylestr ;
?>

تو, just put this code in your foo.php that computes the string $stylestr and you are done. But our trouble is that we are working in the WordPress plugin framework, and cannot use the header() calls. When you try to do that, you will get the error message saying that header is already done dude. For this problem, I found the ingenious solution in one of the plugins that I use. Forgot which one, but I guess it is a common technique. The solution is to define an empty iFrame and set its source to what the PHP function would write. Since iFrame expects a full HTML source, you are allowed (حقیقت میں, obliged) to give the header() directives. The code snippet looks something like:

<iframe id="saveCSS" src="about:blank" style="visibility:hidden;border:none;height:1em;width:1px;"></iframe>
<script type="text/javascript">
var fram = document.getElementById("saveCSS");
<?php echo 'fram.src = "' . $styleurl .'"' ;
?>

Now the question is, what should the source be? دوسرے الفاظ میں, what is $styleurl? واضح طور پر, it is not going to be a static file on your server. And the purpose of this post is to show that it doesn’t have to be a file on the server at all. It is a two-part answer. You have to remember that you are working within the WordPress framework, and you cannot make standalone php files. The only thing you can do is to add arguments to the existing php files, or the plugins you have created. So you first make a submit button as follows:

<form method="post" action="<?php echo $_SERVER["REQUEST_URI"]?>">
<div class="submit">
<input type="submit" name="saveCSS" title="Download the tweaked stylesheet to your computer" value="Download Stylesheet" />
</div>

Note that the name attribute of the button is “saveCSS.” اب, in the part of the code that handles submits, you do something like:

<?php
if (isset($_POST['saveCSS']))
$styleurl = get_option('siteurl') . '/' . "/wp-admin/themes.php?page=theme-tweaker.php&save" ;

?>

This is the $styleurl that you would give as the source of your iFrame, fram. Note that it is the same as your pluging page URL, except that you managed to add “?save” at the end of it. The next trick is to capture that argument and handle it. For that, you use the WordPress API function, add_action as:

<?php
if (isset($_GET['save'] ))
add_action('init', array(&$thmTwk, 'saveCSS'));
else
remove_action('init', array(&$thmTwk, 'saveCSS'));
?>

This adds a function saveCSS to the init part of your plugin. Now you have to define this function:

<?php
function saveCSS() {
header('Content-Disposition: attachment; filename="style.css"');
header("Content-Transfer-Encoding: ascii");
header('Expires: 0');
header('Pragma: no-cache');
$stylestr = "Whatever string you want to save";
ob_start() ;
print $stylestr ;
ob_end_flush() ;
die() ;
}
?>

Now we are almost home free. The only thing to understand is that you do need the die(). If your function doesn’t die, it will spew out the rest of the WordPress generated stuff into your save file, appending it to your string $stylestr.

It may look complicated. ٹھیک ہے, I guess it is a bit complicated, but once you implement it and get it running, آپ کر سکتے ہیں (and do) forget about it. کم از کم, مجھے کیا کرنا. That’s why I posted it here, so that the next time I need to do it, I can look it up.

Geeks

I have been doing a bit of geeky stuff lately — writing ورڈپریس پلگ ان. ٹھیک ہے, it is because I’m suffering from a terrible writer’s block.

تم نے دیکھا, I’m supposed to be working on my next book. I foolishly promised a couple of chapters of ماتراتمک ترقی کے اصول to my commissioning editor at John Wiley & Sons within a month; now I find myself writing everything other than those darned chapters! Including plugins. اس کے بارے میں سوچنا آ, writing those chapters wouldn’t be any less geeky, گے یہ?

That made me wonder… We all started off as geeks, didn’t we? No use denying it. Remember how our teachers loved us, and the sexy cheerleaders, اچھی طرح سے, didn’t? Later in life, due to exigencies of circumstances, we may have tried to lose our techie halo and simulate a managerial posture. لیکن, in our moments of panic, we go back to our geek roots. کم از کم, مجھے کیا کرنا.

You think you don’t? ٹھیک ہے, check out these geek jokes. If you find them funny, chances are your roots are not too different from mine.

Heisenberg was driving down the highway when he was pulled over for speeding. The officer says, “Do you know how fast you were going?” Heisenberg says, “نہیں, but I do know where I am!”

Two Hydrogen atoms walk into a bar. One says, “I’ve lost my electron!” The other says, “Are you sure?” The first replies, “جی ہاں, I’m positive…”

Geek Pickup Lines:

  • Tell me of this thing you humans call [dramatic pause] love.
  • If you turn me down now, I will become more drunk than you can possibly imagine.
  • They don’t call me Bones because I’m a doctor.
  • Your name is Leslie? دیکھو, I can spell your name on my calculator!
  • What’s a nice girl like you doing in a wretched hive of scum and villainy like this?
  • You must be Windows 95 because you got me so unstable.
  • My ‘up-time’ is better than BSD.
  • I can tell by your emoticons that you’re looking for some company.
  • Is that an iPod mini in your pocket or are you just happy to see me.
  • Want to see my Red Hat?
  • If you won’t let me buy you a drink, at least let me fix your laptop.
  • You had me at “Hello World.”
  • Mind if I run a sniffer to see if your ports are open?
  • You make me want to upgrade my Tivo.
  • By looking at you I can tell you’re 36-25-36, which by the way are all perfect squares.
  • Jedi Mind Trick: “This is the geek you’re looking for.” [Waves hand]
  • You can put a Trojan on my Hard Drive anytime.
  • Have you ever Googled yourself?
  • How about we do a little peer-to-peer saliva swapping?
  • With my IQ and your body we could begin a race of genetic superchildren to conquer the earth.
  • What’s a girl like you doing in a place like this when there’s a Farscape marathon on right now on the Sci Fi channel.
  • I’m attracted to you so strongly, scientists will have to develop a fifth fundamental force.

What Makes 100%?

What does it mean to give MORE than 100%? Ever wonder about those people who say they are giving more than 100%? We have all been to those meetings where someone wants you to give over 100%. How about achieving 103%? What makes up 100% in life? Here’s a little mathematical formula that might help you answer these questions:

تو:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z are represented as:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

then H-A-R-D-W-O-R-K = 8+1+18+4+23+15+18+11 = 98%

and K-N-O-W-L-E-D-G-E = 11+14+15+23+12+5+4+7+5 = 96%

but A-T-T-I-T-U-D-E = 1+20+20+9+20+21+4+5 = 100%

and B-U-L-L-S-H-I-T = 2+21+12+12+19+8+9+20 = 103%

but look how far ass kissing will take you.

A-S-S-K-I-S-S-I-N-G = 1+19+19+11+9+19+19+9+14+7 = 118%

تو, one can conclude with mathematical certainty that While Hard work and Knowledge will get you close, and Attitude will get you there, it’s the Bullshit and Ass kissing that will put you over the top.

میٹنگ بنگو کھیل

This one is a hilarious piece I found on the Web. If you really like it, آپ تعجب کرنا ہے — am I still doing too much techie stuff and too little management?

Ever been in a mind-numbing meeting with some MBA-type spewing forth a sequence of buzzwords he read on the back of a Business Careers for Dummies book? Print this out and when you get 7 horizontal, vertical or diagonal, shout BINGO!

& NBSP؛

Synergy Offline Strategic Fit Interface Gap Analysis Best Practice The Bottom Line
Core Business Going Forward Touch Base Revisit Game Plan Learning Curve Revert Urgently
Out of the Loop Go the Extra Mile Benchmark The Big Picture Value Added Movers and Shakers Ballpark
Proactive, not Reactive Win-Win Situation Think Outside the Box Fast Track Results Driven Empowerment Define and Sign Off
Partner Led Business Case Change Management At the End of the Day Local Feedback Ticks in the Boxes Mindset
Knock-On Effect Put this to Bed Client-Focused Quality Driven Move the Goal Posts Process Improvement Bandwidth
Facilitate Knowledge Base Downsize Rocket Science Skill Set Customer Focused Ramp Up

(This joke was found at the ای میل Flotsam page at Mike’s World)