Skip to content

Instantly share code, notes, and snippets.

View vrushank-snippets's full-sized avatar

Vrushank vrushank-snippets

View GitHub Profile
<?php
/* Return object of shared counts */
function get_social_count( $link ) {
$r = (object)array();
$r->facebook = get_social_count_facebook($link);
$r->twitter = get_social_count_twitter($link);
$r->gplus = get_social_count_gplus($link);
return $r;
}
@vrushank-snippets
vrushank-snippets / HTML Template
Created March 23, 2012 10:09
HTML : Starting Template
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title></title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
@vrushank-snippets
vrushank-snippets / Document Ready
Created March 23, 2012 10:14
jQuery : document ready
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// Handler for .ready() called.
});
</script>
@vrushank-snippets
vrushank-snippets / Controller
Created March 23, 2012 10:24
CodeIgniter : controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
$this->load->view('welcome_message');
}
}
@vrushank-snippets
vrushank-snippets / codeigniter_htaccess
Created March 23, 2012 10:27 — forked from muhittin/codeigniter_htaccess
CodeIgniter : htaccess
RewriteEngine On
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1
@vrushank-snippets
vrushank-snippets / Model
Created March 23, 2012 10:30 — forked from etienne-snippet/gist:1993145
CodeIgniter: Model
<?php
class User_model extends CI_Model {
function __construct()
{
parent::__construct();
}
}
@vrushank-snippets
vrushank-snippets / Unzip zip files
Created March 23, 2012 10:36
PHP : Unzip zip files
function unzip_file($file, $destination){
// create object
$zip = new ZipArchive() ;
// open archive
if ($zip->open($file) !== TRUE) {
die (’Could not open archive’);
}
// extract contents to destination directory
$zip->extractTo($destination);
// close archive
@vrushank-snippets
vrushank-snippets / Detect location by IP
Created March 23, 2012 10:39
PHP : Detect location by IP
function detect_city($ip) {
$default = 'UNKNOWN';
if (!is_string($ip) || strlen($ip) < 1 || $ip == '127.0.0.1' || $ip == 'localhost')
$ip = '8.8.8.8';
$curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)';
$url = 'http://ipinfodb.com/ip_locator.php?ip=' . urlencode($ip);
@vrushank-snippets
vrushank-snippets / Automatic password creation
Created March 23, 2012 10:46
PHP : Automatic password creation
function generatePassword($length=9, $strength=0) {
$vowels = 'aeuy';
$consonants = 'bdghjmnpqrstvz';
if ($strength >= 1) {
$consonants .= 'BDGHJLMNPQRSTVWXZ';
}
if ($strength >= 2) {
$vowels .= "AEUY";
}
if ($strength >= 4) {
@vrushank-snippets
vrushank-snippets / Automatically remove html tags from a string
Created March 23, 2012 10:54
PHP : Automatically remove html tags from a string
$text = strip_tags($input, "");