Skip to content

Instantly share code, notes, and snippets.

View itsbalamurali's full-sized avatar
🎯
Focusing

Balamurali Pandranki itsbalamurali

🎯
Focusing
View GitHub Profile
@itsbalamurali
itsbalamurali / gravatar_function.php
Created November 27, 2012 07:08
Simple PHP Gravatar Function
<?php
/**
Load a gravatar.
*/
function gravatar($email = '', $rating = 'pg') {
$default = "path/to/defava.png"; // Set a Default Avatar
$email = md5(strtolower(trim($email)));
$gravurl = "http://www.gravatar.com/avatar/$email?d=$default&s=60&r=$rating";
return '<img src="'.$gravurl.'" width="60" height="60" border="0" alt="Avatar">';
@itsbalamurali
itsbalamurali / php-db-backup.php
Created June 11, 2013 08:15
Class to back up entire databases and email them out, or individual tables.
<?php
class Backup
{
/**
* @var stores the options
*/
var $config;
/**
* @var stores the final sql dump
@itsbalamurali
itsbalamurali / gist:5917274
Created July 3, 2013 11:49
Google Maps Api Coodrinates
$("#SomeIDOfATextBox").val("Some value");
//Can be replaced by:
document.getElementById('SomeIDOfATextBox').value = "Some value";
@itsbalamurali
itsbalamurali / date_time.html
Created July 24, 2013 10:30
Display Date and Time in Javascript The script is simple, we will use the Javascript Object Date to get the date and the time. We will display the month in words(January, February...).
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Display Date and Time in Javascript</title>
<script type="text/javascript" src="date_time.js"></script>
</head>
<body>
<span id="date_time"></span>
<script type="text/javascript">window.onload = date_time('date_time');</script>
@itsbalamurali
itsbalamurali / .htaccess
Created September 3, 2013 06:38
Force Secure (SSL) Pages With .htaccess
RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://domain.com/$1 [R,L]
#
# Inspired by
# http://dev.rubyonrails.org/svn/rails/plugins/account_location/lib/account_location.rb
#
module SubdomainAccounts
def self.included( controller )
controller.helper_method(:account_domain, :account_subdomain, :account_url, :current_account, :default_account_subdomain, :default_account_url)
end
protected
@itsbalamurali
itsbalamurali / chat.rb
Created October 20, 2013 16:09 — forked from rkh/chat.rb
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
require 'hub'
run Sinatra::Application
require 'hub'
run Sinatra::Application
@itsbalamurali
itsbalamurali / index.php
Last active December 28, 2015 09:29
Bing Images puller in action http://bingy.herokuapp.com/
<?php
//Bing Images puller in action http://bingy.herokuapp.com/
//this snippet will get the bing.com's current image
$bingimgxml = file_get_contents('http://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1&mkt=en-US');
$bg_img = new SimpleXMLElement($bingimgxml);
$image = $bg_img->image->url;
$img_url ="http://www.bing.com$image";
header('Content-Type: image/jpeg');
readfile($img_url);
//echo $img_url;