Skip to content

Instantly share code, notes, and snippets.

View kanakiyajay's full-sized avatar
💭
Reach out to my email address

Jay Kanakiya kanakiyajay

💭
Reach out to my email address
View GitHub Profile
@kanakiyajay
kanakiyajay / concat.js
Created July 13, 2015 06:16
Array concatenation into another array
var arrayA = [1, 2];
var arrayB = [3, 4];
var newArray = arrayA.concat(arrayB);
@kanakiyajay
kanakiyajay / Gruntfile.js
Created June 13, 2015 11:17
This Gruntfile.js will clean your dist folder, concat & minify all js, css assets according config specified in html, put revisions, minify html and copy new folder structure to dist.
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
clean: ['dist'],
copy: {
generated: {
src: 'src/index.html',
dest: 'dist/index.html'
@kanakiyajay
kanakiyajay / template.js
Created June 7, 2015 18:08
Quick Templating Engine for javascript
function template(s,d){
for(var p in d)
s=s.replace(new RegExp('{'+p+'}','g'), d[p]);
return s;
}
template('Hello {name}', {name: 'Jay'});
@kanakiyajay
kanakiyajay / Gruntfile.js
Created May 3, 2015 05:05
Gruntfile.js and package.json utilizing load-grunt-tasks, copy, concat, cssmin, htmlmin, uglify, filerev
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
copy: {
generated: {
src: 'index.html',
dest: 'dist/index.html'
}
console.log("SHOPS: {% if shop.customer_accounts_enabled %}");
@kanakiyajay
kanakiyajay / functions.php
Created January 26, 2015 14:56
Collections of code for your wordpress functions.php file
// CUSTOM ADMIN MENU LINK FOR ALL SETTINGS
function all_settings_link() {
add_options_page(__('All Settings'), __('All Settings'), 'administrator', 'options.php');
}
add_action('admin_menu', 'all_settings_link');
add_filter( 'login_headerurl', 'namespace_login_headerurl' );
/**
* Replaces the login header logo URL
*
@kanakiyajay
kanakiyajay / cols.css
Created December 1, 2014 05:04
Seven Equal Columns in bootstrap.
@media (min-width: 768px) {
.seven-cols .col-md-1,
.seven-cols .col-sm-1,
.seven-cols .col-lg-1 {
width: 100%;
}
}
@media (min-width: 992px) {
.seven-cols .col-md-1,
@kanakiyajay
kanakiyajay / .htaccess
Created November 29, 2014 14:49
.htaccess files for wordpress for gzip and security.
<FilesMatch "^(wp-config\.php|wp-cache-config\.php|advanced-cache\.php|php\.ini|php5\.ini|config\.php|db\.php|db-config\.ini)">
Order Deny,Allow
Deny from all
</FilesMatch>
### If you have one or more dedicated IP addresses, uncomment the below
### from <FilesMatch to </FilesMatch then replace the IP addresess with
### your own; and completely remove any IP address line not necessary.
###
### For example, if you only have one dedicated IP address, there
@kanakiyajay
kanakiyajay / trackingService.js
Created November 28, 2014 15:12
Tracking Google Analytics in Angular js Apps
MyApp.run(function($rootScope, $location, $routeParams, $window){
$rootScope.$on('$routeChangeSuccess', function() {
var output=$location.path()+"?";
angular.forEach($routeParams,function(value,key){
output+=key+"="+value+"&";
})
output=output.substr(0,output.length-1);
$window._gaq.push(['_trackPageView', output]);
});
})
@kanakiyajay
kanakiyajay / onbeforeunload.js
Created November 20, 2014 12:51
javascript snippet to alert user from not leaving
window.onbeforeunload = function (e) {
e = e || window.event;
// For IE and Firefox prior to version 4
if (e) {
e.returnValue = 'Sure?';
}
// For Safari
return 'Sure?';