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
validates_inclusion_of :birthday,
:in => Date.new(1900)..Time.now.years_ago(18).to_date,
:message => 'Too young, dude!'
FB.Event.subscribe('edge.create', function(targetUrl) {
_gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]);
});
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!");
});
@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
@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 / 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 / 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 / UUID_Generator.php
Created January 5, 2013 06:16
Generate UUID for Images
//UUID generator
function _imgName() {
return time() . substr(md5(microtime()), 0, 12);
}