Skip to content

Instantly share code, notes, and snippets.

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

Sanjay Rohila crazyrohila

🏠
Working from home
View GitHub Profile
@crazyrohila
crazyrohila / resizetocover.js
Last active December 18, 2015 13:29
html image scaled and cropped to behave like background cover in a div.
(function($) {
$.fn.resizeToCover = function () {
this.each(function() {
if($(this).is('img')) {
var viewport = $(this).parent();
var img = $(this);
var org_img = new Image();
org_img.src = img.attr("src");
var image_original_width = org_img.width;
var image_original_height = org_img.height;
@crazyrohila
crazyrohila / _mixins.scss
Created August 3, 2013 11:08
Some Mixins
/**
* Some mixins I use when not including compass/bourbon in project.
*/
@mixin vendor($property, $value) {
-webkit-#{$property}:$value;
-moz-#{$property}:$value;
-ms-#{$property}:$value;
-o-#{$property}:$value;
#{$property}:$value;
@crazyrohila
crazyrohila / Change value of dependent fields in drupal by Ajax request
Last active December 20, 2015 14:28
Ajax Request in drupal Module by javascript
We have to change a field value when changing other field. Drupal Ajax menu is right method, but I found other way easier.
hook_menu :- Create a url with hook_menu.
page_callback :- In page callback we have to process all things and return data (in json format) that will need in javascript.
drupal_add_js :- Now use $.get method in js and hit that url and parse json ($.parseJSON) data from response and perform other actions.
/*======== Code Example==========*/
@crazyrohila
crazyrohila / dbsync.sh
Created August 5, 2013 17:49
This is shell script to take backup from server and update db to local system.
#! /bin/bash
#This is very simple script. All commands will run one by one. So If any command will fail, Script will not stop.
#You Should have install drush on server and provide ssh password.
ssh <USER>@<SERVER> "drush -r <DRUPAL_ROOT_DIR> sql-dump|bzip2 -c" > db.sql.bz2
echo 'db dump from server';
bunzip2 db.sql.bz2
echo 'unziped db';
#Delete the old db replace <password> with original password (without any space after -p).
@crazyrohila
crazyrohila / deploy.php
Created August 14, 2013 07:37
A lazy man's drupal deploy script.
<?php
exec('git pull && drush cc all', $output);
/**
* Pull from specific branch.
* eg. exec('git pull origin <branchname> && drush cc all', $output);
*/
print_r($output);
@crazyrohila
crazyrohila / arrows.scss
Last active December 22, 2015 17:19
A mixin to create arrows.
/**
* variables:-
* @width: horizontal length of arrow.
* @height: vertical length of arrow.
* @dir: dirction of arrow. eg. top, right, bottom, left.
* @bg: color of arrow.
*/
@mixin arrows($width, $height, $dir, $bg) {
width: $width;
@crazyrohila
crazyrohila / buttons.scss
Last active December 30, 2015 11:18
SCSS mixin for generating 3D button
/**
* variables:-
* @bgcolor: background color.
* @color: font color in button.
* @shdow-depth: depth for box-shadow around button.
*/
@mixin button($bgcolor, $color, $shadow-depth) {
// Box shadow array.
@crazyrohila
crazyrohila / css-loading-spinner.scss
Created December 6, 2013 09:57
Loading spinner with css. single element. no images.
/**
* Inspired by lea verou's cleanest spinner.
* http://lea.verou.me/2013/11/cleanest-css-spinner-ever/
*
* Configurable with 4 variables.
* $closeness: gap between bars.
* $length: length of each bars in px.
* $thickness: thickness of each spinner bars.
* $color: color of bars. In some color it won't work properly eg. "red".
*/
@crazyrohila
crazyrohila / regex-snippet
Created April 22, 2014 07:50
Sublime Regex Snippet
// Find some words with numbers numbers
1) breakpoint\((\d+)\)
@crazyrohila
crazyrohila / SassMeister-input.scss
Created July 22, 2014 07:04
Generated by SassMeister.com.
// ----
// Sass (v3.3.10)
// Compass (v1.0.0.alpha.20)
// ----
@mixin x-rem($property, $values) {
$base-font-size: 10px;
$px-values: ();
$rem-values: ();