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 / cakephp-shared-htaccess
Last active August 4, 2020 12:38
CakePHP on GoDaddy Shared Hosting .htaccess settings
#Need to add three .htaccess files as well as configure the database.php file
####### In the root directory
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
let counter = 0;
function doSomethingAsync(id, start) {
return new Promise(resolve => {
setTimeout(() => {
counter++;
const stop = new Date();
const runningTime = getSeconds(start, stop);
resolve(`result${id} completed in ${runningTime} seconds`);
}, 2000);
@harshamv
harshamv / gist:18ff6dcbf576636da199cd99f1baea94
Created September 20, 2016 05:17
Nomad Google Maps Js
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBkg1vwaBHSPzbhrQoyThpxYmZF24Py-ok"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#venue_country_id").change(function(){
var country_id = $(this).val();
console.log(country_id);
$.ajax({
@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);
}
@harshamv
harshamv / maps.js
Created May 12, 2015 07:07
Maps Options
<script type="text/javascript">
var map;
var geocoder;
var service;
var mapOptions = {
center: new google.maps.LatLng(12.971599, 77.594563),
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP
/ Form excerpt
= f.button t(".save"), class: "btn"
= f.button t(".publish"), class: "btn", name: "publish"
= f.button t(".test"), class: "btn", name: "test"