Tips & Tricks
Search Google like a pro
by Binod on Feb.27, 2012, under General, Tips & Tricks
Whenever I go for teaching or some presentation or sometime when I’m in Facebook. Many of my students and junior ask me some question. Whenever I Google it I find the solution in the top or the first link. When replying back why don’t u Google it? They just answer me ‘Google doesn’t give me the result.’ That means you gys are not using Google in an efficient way. Google is a powerful tool, but you’re missing out on a lot of that power if you just type words into it. Master Google and find the best results faster with these search tricks.
Exact Words and Phrases
One of the most basic and widely known search tricks is using quotation marks to search for an exact phrase. For example, perform the following search and you’ll only get pages that contain the word “Hello” followed by the word “World.”
“Hello World”
This same method now works for exact-word queries. For example, if you search for “mining,” Google will also show pages that contain the words “miners.” Previously, you’d use a plus sign and search for +mining, but now you have to enclose the word in quotes:
“mining”
Excluding a Word
The minus sign allows you to specify words that shouldn’t appear in your results. For example, if you’re looking for pages about Windows software that don’t mention linux, use the following search:
windows software -linux
Site Search
The site: operator allows you to perform a search in a specific site. Let’s say you’re looking for information on Windows 7 on binodranabhat.com.np. You could use the following search
site:binodranabhat.com.np windows 7
You can also use the site: operator to specify a domain. For example, if you’re looking for high-quality references, you could use site:.edu to only pull up results from .edu domains.
Related Words
The tilde (~) operator is the opposite of enclosing a single word in quotes — it searches for related words, not just the word you type. For example, if you ran the following search, you’d find search results with words similar to “geek”:
~geek
Apparently, “Linux” is the most similar word to geek, followed by “Greek.” “Nerd” comes in third. (Hey, no one ever said Google was perfect.)
The Wildcard
The asterisk (*) is a wildcard that can match any word. For example, if you wanted to see what companies Google has purchased and how much they paid, you could use this search:
“google purchased * for * dollars”
Time Ranges
A little-known search operator allows you to specify a specific time range. For example, use the following search to find results about Ubuntu from between 2008 and 2010:
ubuntu 2008..2010
File Type
The filetype: operator lets you search for files of a specific file type. For example, you could search for only PDF files.
filetype:pdf guide to php programming
One Word or the Other
The “OR” operator lets you find words that contain one term or another. For example, using the following search will pull up results that contain either the word “Ubuntu” or the word “Linux.”
ubuntu OR linux
Word Definitions
You don’t have to Google a word and look for a dictionary link if you want to see its definition. Use the following search trick and you’ll see an inline definition:
define:word
Calculator
Use Google instead of pulling one out or launching a calculator app. Use the +, -, * and / symbols to specify arithmetic operations. You can also use brackets for more complicated expressions. Here’s an example:
(7 + 5) * (9 / 3)
Unit Conversions
The calculator can also convert between units. Just type “X [units] in [units]”. Here’s an example:
5 kilometers in meters
Combine these search operators to create more complex queries. Want to search a specific website for a PDF file, created between 2001 and 2003, that contains a specific phrase but not another phrase? Go ahead.
How to Reset Windows 7 or Vista Password
by Binod on Jan.07, 2012, under Hacking, Technology, Tips & Tricks, Windows
How to Reset Windows 7 or Vista Password(Helpful when you forgot your Computer’s Password)
If somehow you have forgotten your windows password and are looking for way around to login back into your computer then you won’t have to worry.There are many methods are available for resetting password of your windows 7 or vista.But many of them are lengthy or sophisticated.This is one of the simplest method and you only need a windows installation CD/USB to reset the password.It relies on an unpatched bug in windows operating system.
Follow the Following steps:
Insert windows 7 disk into your CD Rom and Restart your computer.
Press any key to Boot from the CD and then click on Repair your Computer.
Now from the various options select Command Prompt.
Now Command Prompt will be open and create a backup of Sticky keys by typing the following command in the command prompt
copy c:\windows\system32\sethc.exe c:\
Now replace sticky keys with the Command Prompt by typing the following command
copy c:\windows\system32\cmd.exe c:\windows\system32\sethc.exe
Now Restart your computer.
When you get the windows login screen then hit Shift button for 5 times continuously and Administrative Mode of Command Prompt will be open.
Now to reset the password just type the following command in the command prompt
net user binod Password
Remember: binod is the username of the computer and Password is the password. Replace both as you wish.
Login in your computer system with your new Username and Password.
Now every time when you press Shift key for 5 times then command prompt will be open instead of Sticky keys. To get back these Sticky keys repeat first three steps and then in the command prompt window type the following command.
copy c:\sethc.exe c:\windows\system32\sethc.exe
Embed your font in website
by Binod on Sep.17, 2011, under Tips & Tricks, Tutorial, Web Designing
I was thinking to embed my own font to the website but How?? suppose i am making a website with a nepali font ie Preeti. But the problem is there is no font installed in my clients computer, so i receive the unwanted output. to fix it i started to search n finally i m with the solution. Here it goes.
Demo Font Taken is “PREETI_1.TTF”
To embed this font on your web page, you will need to place the following CSS code in the <head> section of your page, or in an external CSS file:
<style type="text/css">
@font-face {
font-family: MyCustomFont;
src: url("PREETI_1.eot") /* EOT file for IE */
}
@font-face {
font-family: MyCustomFont;
src: url("PREETI_1.TTF") /* TTF file for CSS3 browsers */
}
</style>
Note that in the code above, “MyCustomFont” can be any name you want. You will probably want to set this to be the real name of your font.
To use your embedded font, you can simply refer to it by name like you do with any other font. Some examples:
body {
font-family: MyCustomFont;
font-size: medium;
color: black
}
span.header {
font-family: MyCustomFont;
font-weight: bold;
color: red
}
Don’t see your font?
There are two likely reasons why your font isn’t working. First, make sure you’re using a browser that supports embedding fonts. Firefox 3.5 and Internet Explorer 4+ are browsers that support them. If you’re not using a browser that supports embedded fonts, you won’t see your font in the example above.
Cheers !! Enjoy Your Fonts in Your Website. let the client see what you want to show
Write your sentence in reverse order [string manipulation]
by Binod on Sep.17, 2011, under PHP, Tips & Tricks
Its time for fun. after writing few blogs about PHP basics syntax i wished to play with strings. I want to Display the sentence in a reverse order.
Suppose i have a sentence “ Hello Binod How Are you” i wish to display it as “you Are How Binod Hello”
Enjoy the Code. Here it goes.
<?php
$str = “Hello Binod How Are you”;
$str_arr = explode(” “, $str);
$str_rev = array_reverse($str_arr);
foreach($str_rev as $word){
echo $word;
echo ” “;
}?>
Useful string functions for web development
by Binod on Sep.14, 2011, under PHP, Technology, Tips & Tricks
Here i have shared some useful string manipulation functions that can be very important in website development. I had not explained it but the explanation code is all here. i guess the example will explain itself. if you need any help feel free to comment.
<?php
$string_a = “This is a long string”;
$string_b = “This is a much longer string”;
$explode_arr = explode(” “, $string_a);
print “<br>”.$explode_arr[3];// will pirnt long
$string_n = “This is line 1.\nThis is line 2″;
print “<br>”.nl2br($string_n);
$result = strcmp($string_a, $string_b);//can be useful for password comparision
if($result == 0){
print “<br>”.”String A and B are equal”;
}
elseif($result < 0){
print “<br>”.”String A is less than String B.”; //this is printed
}
elseif($result > 0 ) {
print “<br>”.”String A is greater than String B.”;
}
$length = strlen ($string_b);
print “<br><br>”.”String length of string ‘$string_b’ is $length.”;
print “<br><br>”.”Lower case of string $string_a is -> “.strtolower($string_a).”.”;
print “<br><br>”.”Uppder case of string $string_a is -> “.strtoupper($string_a).”.”;
$sub_string_1 = substr ($string_b, -6);
print “<br><br>Substring 1 “.$sub_string_1;
$sub_string_2 = substr ($string_b, 0, 7);
print “<br><br>Substring 2 “.$sub_string_2;
//try some substring variations yourself
$string_t = “ Binod Ranabhat “;
print “<br><br>String lenghth without trimming -”.strlen($string_t).”- and String length after trim -”.strlen(trim($string_t)).”-.”;
//try ltrim and r trim youself.
?>
The output will be as
long
This is line 1.
This is line 2
String A is less than String B.
String length of string ‘This is a much longer string’ is 28.
Lower case of string This is a long string is -> this is a long string.
Uppder case of string This is a long string is -> THIS IS A LONG STRING.
Substring 1 string
Substring 2 This is
String lenghth without trimming -21- and String length after trim -14-.
Difference between .MSI files and .EXE files
by Binod on Sep.11, 2011, under General, Technology, Tips & Tricks
MSI files are database files, used by Windows Installer. They contain information about an application which is divided into features and components, and every component may hold files, registry data, shortcuts etc. The MSI file also contains the UI that is to be used for installing, and various other data such as any prerequisites to look for, custom actions to execute, the order of the installation procedure, whether to support Administrative installations, etc. It can also contain the actual files to be installed themselves (this isn’t always the case though, the files can also be in an external CAB file or just as plain uncompressed files in a location where MSI can find them).
MSI files are the current recommended way of doing installations on Windows. The alternative is writing a program that performs the installation itself.
MSI files are executed by an EXE file that is part of Windows, called MSIEXEC.EXE. This application reads the data in the MSI file and executes the installation.
Windows Installer is pretty new, especially the newest version (3.0). Often installations that use MSI still come with an EXE (e.g. SETUP.EXE). This EXE is a so-called ‘bootstrapper’. It doesn’t perform the installation, it simply checks if the correct version of Windows Installer is present on the system, if not it launched the MSI Redistributable (MsiInstA.exe or MsiInstW.exe depending on the platform) and then launches MSIEXEC.EXE on the MSI file. In certain cases (especially Internet downloads), the MSI file and MSI redistributable are packed inside that EXE file, so you don’t see they’re there.
So installations can come in three flavours:
- A custom, third-party installation system in an EXE file.
- A Windows Installer installation in an MSI file.
- An EXE file that bootstraps an MSI file (that may be embedded inside the EXE file).
MSI files can only be installations. EXE files can be literally anything that can run on your computer.
Post Increment and Pre increment
by Binod on Sep.10, 2011, under PHP, Tips & Tricks
Most of the Programmer along with me are confused in Post Increment/decrement and Pre Increment/decrement of the Operator. I am here posting an example of Post Increment and Pre increment done in PHP. This must help us all.
<?php
$a = 5;
echo “<h2>A initially is “.$a.”.</h2>”;
echo “<h3>Postincrement</h3>”;
echo “Should be 5: ” . $a++ . “<br />\n”;
echo “Should be 6: ” . $a . “<br />\n”;
echo “<h3>Preincrement</h3>”;
$a = 5;
echo “A is reset to: “.$a. “<br />\n”;
echo “Should be 6: ” . ++$a . “<br />\n”;
echo “Should be 6: ” . $a . “<br />\n”;
echo “<h3>Postdecrement</h3>”;
$a = 5;
echo “A is reset to: “.$a. “<br />\n”;
echo “Should be 5: ” . $a– . “<br />\n”;
echo “Should be 4: ” . $a . “<br />\n”;
echo “<h3>Predecrement</h3>”;
$a = 5;
echo “A is reset to: “.$a. “<br />\n”;
echo “Should be 4: ” . –$a . “<br />\n”;
echo “Should be 4: ” . $a . “<br />\n”;
?>
The Output will be
A initially is 5.
Postincrement
Should be 5: 5
Should be 6: 6
Preincrement
A is reset to: 5
Should be 6: 6
Should be 6: 6
Postdecrement
A is reset to: 5
Should be 5: 5
Should be 4: 4
Predecrement
A is reset to: 5
Should be 4: 4
Should be 4: 4
Passing JavaScript variables to PHP
by Binod on Aug.28, 2011, under Javascript, PHP, Tips & Tricks, Tutorial, Web Designing
What if I can pass variables between 2 scripting language. JavaScript is mainly used as a client side scripting language, while PHP is a server side technology. Unlike Java or ASP.Net, PHP doesn’t have tools to make it work client side. That is why you need to combine JavaScript and PHP scripts to develop powerful web-applications.
One of the frequent problems is defining visitor’s screen resolution using JavaScript tools and passing this data to PHP-script. The following script provides solution for this problem:
<!—index.htm –>
<script type=”text/javascript”>
width = screen.width;
height = screen.height;
if (width > 0 && height >0) {
window.location.href = “http://localhost/main.php?width=” + width + “&height=” + height;
} else
exit();
</script>
Copy and paste this code snippet in the text editor, save it as index.htm and run it in your browser. After this code has been executed, a user is automatically redirected to the main.php page where screen resolution is displayed in the browser window.
The main.php looks as follows:
<!—main.php –>
<?php
echo “<h1>Screen Resolution:</h1>”;
echo “Width : “.$_GET['width'].”<br>”;
echo “Height : “.$_GET['height'].”<br>”;
?>
As you can see, passing JavaScript variables in PHP is similar to sending data using GET method.
Get File Extension in PHP
by Binod on Aug.28, 2011, under PHP, Tips & Tricks, Tutorial, Web Designing
Today I will be sharing some piece of code for getting the real file extension of the uploaded file. I was working on the CMS few days back and there I made the file upload section but I didn’t checked which type of file is been uploaded. During my testing phase I just tested for jpeg file.[ as it was my target]. I hosted it over my server, it was working fine…
The next day, I received a wall post on Facebook from my friend. Binod, you got a security flaw in ur script. I checked it. What he did was he uploaded his scripted file [PHP file] thru that upload section and started to traverse my whole server files.
Then, I realized I need to check the extension of the file and to block the unwanted extension. (E.g. “php” from “myscript.php”).
Here is some piece of code of my CMS that will be beneficial for the users.
//for the upload page
<input type=”file” name=”myfile” />
//for the submit page
$fileatt = $_FILES['myfile']['tmp_name'];
$filename = $_FILES['myfile']['name'];//there are Five ways that may be helpful
// 1. The “explode/end” approach
$ext = end(explode(‘.’, $filename));// 2. The “strrchr” approach
$ext = substr(strrchr($filename, ‘.’), 1);// 3. The “strrpos” approach
$ext = substr($filename, strrpos($filename, ‘.’) + 1);// 4. The “preg_replace” approach
$ext = preg_replace(‘/^.*\.([^.]+)$/D’, ‘$1′, $filename);//5. The “pathinfo” approch
$ext = pathinfo($filename, PATHINFO_EXTENSION);//Checking The uploaded
if(($ext==”jpg”)||($ext==”jepg”)||($ext==”gif”)||($ext==”png”)){
// Uploading and processing script
}else{
// Error script amd msg
}
Know the sex of your PC
by Binod on Aug.25, 2011, under FuN, Technology, Tips & Tricks
You Might Wonder to know if ur PC is a MALE or FEMALE
GO find it in some steps.
- Create a new .txt file
- write
CreateObject(“SAPI.SpVoice”).Speak”I Love You”
- save your file as computer_gender.vbs
- then run the file
- You will listen the voice…
if its male ur PC is male.. and if its female its female…