Skip to content

Instantly share code, notes, and snippets.

View aslamdoctor's full-sized avatar
💭
Always working but happy to talk 👍

Aslam Doctor aslamdoctor

💭
Always working but happy to talk 👍
View GitHub Profile
@aslamdoctor
aslamdoctor / imageRestrict.php
Created January 19, 2012 14:03
Image Resizing based on Width & Height
<?php
function imageRestrict($image, $maxwidth, $maxheight) {
list($width,$height) = getimagesize($image);
if ($width > $maxwidth) {
$newheight = $maxwidth/$width * $height;
if($newheight > $maxheight){
@aslamdoctor
aslamdoctor / eMailHelper.php
Created January 19, 2012 14:09
All in One PHP Mail Function
<?php
function send_mail($from, $from_name, $to, $to_name, $subject, $body, $attachment="")
{
include_once("phpmailer.class.php");
$mail = new PHPMailer();
$mail->From = $from;
$mail->FromName = $from_name;
$mail->Subject = $subject;
$search = array(
@aslamdoctor
aslamdoctor / dummyHtmlContent.html
Last active September 29, 2015 17:47
Dummy HTML Content including all common elements
<p><a href="#"><img class="size-thumbnail wp-image-58 alignright" alt="" src="http://lorempixel.com/g/500/300/people/1/"></a>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur quam augue, vehicula quis, tincidunt vel, varius vitae, nulla. Sed convallis orci. Duis libero orci, pretium a, <a href="#">convallis quis</a>, pellentesque a, dolor. Curabitur vitae nisi non dolor vestibulum consequat.</p>
<blockquote>
<p>Proin vestibulum. Ut ligula. Nullam sed dolor id odio volutpat pulvinar. Integer a leo. In et eros at neque pretium sagittis. Sed sodales lorem a ipsum suscipit gravida. Ut fringilla placerat arcu. Phasellus imperdiet. Mauris ac justo et turpis pharetra vulputate.</p>
</blockquote>
<p><cite><a href="#">Quote Source</a></cite></p>
<h1>Level 1 Heading</h1>
<h2>Level 2 Heading</h2>
<h3>Level 3 Heading</h3>
<h4>Level 4 Heading</h4>
<h5>Level 5 Heading</h5>
@aslamdoctor
aslamdoctor / dummyPosts.xml
Created January 19, 2012 14:37
Wordpress Dummy Content
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your blog. -->
<!-- It contains information about your blog's posts, comments, and categories. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your blog. -->
<!-- To import this information into a WordPress blog follow these steps. -->
<!-- 1. Log into that blog as an administrator. -->
<!-- 2. Go to Manage: Import in the blog's admin panels. -->
<!-- 3. Choose "WordPress" from the list. -->
@aslamdoctor
aslamdoctor / CreditCardValidation.js
Created February 1, 2012 06:34
CreditCard Validation using Javascript
function isValidCreditCard(type, ccnum) {
if (type == "Visa") {
// Visa: length 16, prefix 4, dashes optional.
var re = /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/;
} else if (type == "MC") {
// Mastercard: length 16, prefix 51-55, dashes optional.
var re = /^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/;
} else if (type == "Disc") {
// Discover: length 16, prefix 6011, dashes optional.
var re = /^6011-?\d{4}-?\d{4}-?\d{4}$/;
@aslamdoctor
aslamdoctor / jqueryAjax.js
Created February 6, 2012 09:00
jQuery Ajax call
$.ajax({
type: "POST",
url: "submit_ops.php?action=submit_form",
data: $( "#frmMyForm" ).serialize(),
success: function(result){
if(result=='Success'){
$("#msgContainer").html('<div style="color:#3CA322;font-weight:bold;font-size:14px;padding:10px;">Thank you.</div>');
$("#msgContainer").fadeIn();
}
else{
@aslamdoctor
aslamdoctor / jquery-json-php.txt
Created February 25, 2012 13:09
jQuery to PHP via AJAX using JSON
JS Code
------------------
$.ajax({
type: "POST",
url: targetURL,
async: false,
data: JSON.stringify($('#form').serializeArray()),
success: function(data){
console.log(data);
@aslamdoctor
aslamdoctor / delete-duplicate.sql
Created September 19, 2013 07:16
Delete duplicate records from MySQL Database
DELETE FROM table1
USING table1, table1 AS vtable
WHERE (
table1.ID > vtable.ID
)
AND (
table1.field1 = vtable.field1
)
AND (
table1.field2 = vtable.field2
@aslamdoctor
aslamdoctor / blink-text.js
Created September 19, 2013 07:17
Blink Text using jQuery
@aslamdoctor
aslamdoctor / generate-csv.php
Created September 19, 2013 07:20
Generate CSV file from Array using PHP
<?php
function generateCsv($data, $delimiter = ',', $enclosure = '"') {
$handle = fopen('php://temp', 'r+');
foreach ($data as $line) {
fputcsv($handle, $line, $delimiter, $enclosure);
}
rewind($handle);
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}