Skip to content

Instantly share code, notes, and snippets.

View shahariaazam's full-sized avatar
:octocat:
Open for opportunities

Shaharia Azam shahariaazam

:octocat:
Open for opportunities
View GitHub Profile
@shahariaazam
shahariaazam / ping.php
Created January 19, 2013 18:38
How to Ping to a server to check whether it is up or down.
<?php
/**
* @param null $host
* @param null $port
* @param null $timeout
* @return bool|string
*/
function PingToServer($host=null, $port=null, $timeout=null)
{
if(empty($host) || empty($port) || empty($timeout)){
@shahariaazam
shahariaazam / directory_sperator.php
Last active December 11, 2015 18:38
Platform Independent DIRECTORY_ SEPERATOR constant in php
<?php
function TestPath()
{
return __DIR__.DIRECTORY_SEPARATOR."somefile.php";
}
var_dump(TestPath());
/*
* it will return something like string 'C:\xampp\htdocs\LibComponent\Multimedia\somefile.php' (length=58)
* In this case DIRECTORY_SEPERATOR constant is "\" if I want to require somefile.php then this type of path will not work
* but to make it work I need C:/xampp/htdocs/LibComponent/Multimedia/somefile.php
@shahariaazam
shahariaazam / cURL.php
Created February 3, 2013 17:20
cURL code example. It's not tested yet! just to give an example implementation of cURL.
<?php
$username="username";
$password="password";
$url="https://vp1-voiceportal.megapath.com/Login/servlet/com.broadsoft.clients.oam.servlets.Login";
$cookie="cookie.txt";
$postdata = "EnteredUserID=".$username."&password=".$password."&domain=&UserID=&rememberPass=";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
@shahariaazam
shahariaazam / ZIPMaker.php
Created February 3, 2013 17:43
Create .ZIP archive in PHP
<?php
/**
* @Author Shaharia Azam
* @Author URL http://www.shahariaazam.com
*
* @Description this function will make a .zip folder by adding multiple files.
* @link http://php.net/manual/en/book.zip.php
*
* @param array $SourceFiles
* @param string $ZipDestination
<?php
$stmt = $pdo->prepare("SELECT ItemSales.date,
ItemSales.price,
ItemSales.price * ItemSales.quantity as earnings
FROM ItemSales as sales,Items
WHERE ItemSales.itemId = Items.id
AND Items.id = :Items_id"); // Note: :Items.id change to :Items_id
$stmt->bindParam(':Items_id', $id); // Note: 'Items.id' change to ':Items_id'
<?php
//For Database query
$q = $_GET["q"];
$sql = "select * from user where 'username' ="$q;
$query = mysql_query ($sql);
if ($q === 1) {
echo "Yes";
} else {
echo "No";
// Scraping Made Easy with jQuery and SelectorGadget
// (http://blog.dtrejo.com/scraping-made-easy-with-jquery-and-selectorga)
// by David Trejo
//
// Install node.js and npm:
// http://joyeur.com/2010/12/10/installing-node-and-npm/
// Then run
// npm install jsdom jquery http-agent
// node numresults.js
//
@shahariaazam
shahariaazam / json_test.php
Last active December 20, 2015 02:59
Wizpert help for Sridhar
<?php
$curl = curl_init();
$url = "http://search.asu.com/admintool/listingsTest_ASU.php";
//$url ="http://search.asu.com/_data/airports.php";
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POSTFIELDS,null);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // follow redirects
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
@font-face {
font-family: 'Port Lligat Slab';
font-style: normal;
font-weight: 400;
src: url(data:font/opentype;charset=utf-8;base64,d09GRgABAAAAAD00AA4AAAAAepQAAQABAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABRAAAABsAAAAcYA1EIU9TLzIAAAFgAAAAUAAAAGCkS3u1Y21hcAAAAbAAAAF0AAABugd1VkZnYXNwAAADJAAAAAgAAAAIAAAAEGdseWYAAAMsAAAv7QAAZoQiL/V1aGVhZAAAMxwAAAA0AAAANvh1GcdoaGVhAAAzUAAAAB8AAAAkBjEDv2htdHgAADNwAAACCgAAA0iRICeTa2VybgAANXwAAAFiAAACXhxPGMtsb2NhAAA24AAAAaYAAAGmGJf+sm1heHAAADiIAAAAHgAAACABGQBhbmFtZQAAOKgAAAMvAAAHRI37YPJwb3N0AAA72AAAAVMAAAHLpBShdnByZXAAAD0sAAAABwAAAAdoBoyFeJxjYGBgZACCk535hiD6tOMrFij9GgBBaAbPAHicY2Bi7GOcwMDKwMC0h6mLgYGhB0Iz3mUwYvgFFGWAgQYGhvUODAreMH5BZVExA1BAYQ1zzH9dBgbmGIbLCkCNYMlOhmQgqcDACAD+sA8TeJxjYGBgZoBgGQZGBhDYAuQxgvksDDOAtBKDApDFxFDHsJhhDcN/RkPGYKZjTLeY7iiIKEgpyCkoKVgpuCis+f8fqFaBYSHDUoZ1QDVBUDXCChIKMkA1lhA1/x//P/j/wP/9//v+5/398/fl3xcPNj1Y/2Ddg9UPpj7oeaAKdQMBwMjGAFfIyAQkmNAVAL3EwsrGzsHJxc3Dy8cvICgkLCIqJi4hKSUtIysnr6CopKyiqqauoamlraOrp29gaGRsYmpmbmFpZW1ja2fv4Ojk7OLq5u7h6eXt4+vnHxAYFBw
@shahariaazam
shahariaazam / gist_test.php
Created August 18, 2013 05:08
GIST test from local Sublime Text 2
<?php
echo "Thanks";