Skip to content

Instantly share code, notes, and snippets.

View harshamv's full-sized avatar
🏠
Working from home

Harsha MV harshamv

🏠
Working from home
View GitHub Profile
@harshamv
harshamv / UUID_Generator.php
Created January 5, 2013 06:16
Generate UUID for Images
//UUID generator
function _imgName() {
return time() . substr(md5(microtime()), 0, 12);
}
@harshamv
harshamv / url_slug.php
Created January 5, 2013 06:17
Generate URL Slug for CakePHP
// Creates a URL Slug
function _url_slug($string) {
$string = strtolower(trim($string));
$string = preg_replace('/[^a-z0-9-]/', '-', $string);
$string = preg_replace('/-+/', "-", $string);
return $string;
}
// Gets a Unique slug string by checking in the database
@harshamv
harshamv / random_password.php
Created January 5, 2013 06:18
Random Password Generator
// Random Password Generator
function _RandomPasswordGenerator() {
// Create the meta-password
$sMetaPassword = "";
$CONFIG['security']['password_generator'] = array("C" => array('characters' =>
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'minimum' => 4,
'maximum' => 6), "S" => array('characters' => "!@()-_=+?*^&", 'minimum' => 0,
'maximum' => 0), "N" => array('characters' => '1234567890', 'minimum' => 2,
'maximum' => 2));
@harshamv
harshamv / Gemfile
Created February 24, 2013 20:27 — forked from litch/Gemfile
source 'https://rubygems.org'
ruby "2.0.0"
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
...
@harshamv
harshamv / 0_reuse_code.js
Created January 4, 2014 11:04
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
window.fbAsyncInit = function () {
FB.init({
appId: 'APPID',
Status: true,
Cookie: true,
Xfbml: true
});
FB.Event.subscribe('edge.create', function (response) {
Alert("Hello World! URL Liked!");
});
FB.Event.subscribe('edge.create', function(targetUrl) {
_gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]);
});
validates_inclusion_of :birthday,
:in => Date.new(1900)..Time.now.years_ago(18).to_date,
:message => 'Too young, dude!'
function hideAddressBar()
{
if(!window.location.hash)
{
if(document.height < window.outerHeight)
{
document.body.style.height = (window.outerHeight + 50) + 'px';
}
setTimeout( function(){ window.scrollTo(0, 1); }, 50 );
@harshamv
harshamv / .htaccess
Created June 27, 2014 15:19
GZIP Apache Server
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
<IfModule mod_setenvif.c>
# Netscape 4.x has some problems
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip