Skip to content

Instantly share code, notes, and snippets.

View grim-reapper's full-sized avatar

Imran Ali grim-reapper

View GitHub Profile
@grim-reapper
grim-reapper / gist:bba4d301dfa40e8da3ab
Created June 22, 2014 16:47
PHP: simple contact form
<?php
/**
* @author Mad Jack
* simple contact form
*/
if (strtoupper($_SERVER['REQUEST_METHOD'])=="POST") {
$fullname = $_POST['fullname'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$comment = $_POST['message'];
@grim-reapper
grim-reapper / timeAgo.php
Created June 22, 2014 17:04
PHP: Facebook style time ago
<?php
/**
* time since last post
* @author Mad Jack
* @param {int} $time passed time in seconds as param
* @return {datetime} Return formated date and time
*/
function ago($time) {
@grim-reapper
grim-reapper / Cart.php
Last active August 29, 2015 14:06
PHP: Cart Class with Anonymous function
<?php
/**
* MIT License
* ===========
*
* Copyright (c) 2012 MindCracker <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@grim-reapper
grim-reapper / urlPrefixer.php
Last active August 29, 2015 14:06
PHP: Url Prefixer
<?php
/**
* Prefix_protocol This function will search for http://, https://, ftp:// and ftps://, if none of them are in the string then we add the prefix to the start of the string
* @param string $url get url
* @param string $prefix prefixer
* @return string return full url with protocol
* @author Mind Cracker <[email protected]>
*/
function prefix_protocol($url,$prefix='http://')
{
<?php
/* vars for export */
// database record to be exported
$db_record = 'XXXXXXXXX';
// optional where query
$where = 'WHERE 1 ORDER BY 1';
// filename for export
$csv_filename = 'db_export_'.$db_record.'_'.date('Y-m-d').'.csv';
// database variables
@grim-reapper
grim-reapper / demo.php
Last active August 29, 2015 14:06 — forked from tracend/demo.php
<?php
$host = 'localhost'; // MYSQL database host adress
$db = ''; // MYSQL database name
$user = ''; // Mysql Datbase user
$pass = ''; // Mysql Datbase password
// Connect to the database
$link = mysql_connect($host, $user, $pass);
mysql_select_db($db);
/* Pre-Define HTML5 Elements in IE */
(function(){ var els = "source|address|article|aside|audio|canvas|command|datalist|details|dialog|figure|figcaption|footer|header|hgroup|keygen|mark|meter|menu|nav|picture|progress|ruby|section|time|video".split('|'); for(var i = 0; i < els.length; i++) { document.createElement(els[i]); } } )();
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="et">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>table</title>
<style type="text/css">
.odd { background-color: #808080; }
.generated_for_mobile { margin-bottom: 30px }
//EnhanceJS isIE test idea
//detect IE and version number through injected conditional comments (no UA detect, no need for cond. compilation / jscript check)
//version arg is for IE version (optional)
//comparison arg supports 'lte', 'gte', etc (optional)
function isIE(version, comparison) {
var cc = 'IE',
b = document.createElement('B'),
@grim-reapper
grim-reapper / php-webscraping.md
Created November 24, 2015 07:30 — forked from anchetaWern/php-webscraping.md
web scraping in php

Have you ever wanted to get a specific data from another website but there's no API available for it? That's where Web Scraping comes in, if the data is not made available by the website we can just scrape it from the website itself.

But before we dive in let us first define what web scraping is. According to Wikipedia:

{% blockquote %} Web scraping (web harvesting or web data extraction) is a computer software technique of extracting information from websites. Usually, such software programs simulate human exploration of the World Wide Web by either implementing low-level Hypertext Transfer Protocol (HTTP), or embedding a fully-fledged web browser, such as Internet Explorer or Mozilla Firefox. {% endblockquote %}