Skip to content

Instantly share code, notes, and snippets.

//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person
@maheshbabu
maheshbabu / module_pattern_init.js
Created October 6, 2015 10:35 — forked from nathansmith/module_pattern_init.js
Init + Module Pattern JS
// JS Module Pattern:
// http://j.mp/module-pattern
// Redefine: $, window, document, undefined.
var APP = (function($, window, document, undefined) {
// Automatically calls all functions in APP.init
$(document).ready(function() {
APP.go();
});
@maheshbabu
maheshbabu / this-is-madness.css
Created October 6, 2015 10:36 — forked from nathansmith/this-is-madness.css
Examples of CSS selector strength.
* {}
tag {}
[attribute] {}
[attribute="value"] {}
.class {}
@maheshbabu
maheshbabu / Node.js code style tips
Last active February 10, 2016 14:03
Simple node.js code style tips to improve code quality
Whether you use 2 spaces or 4 spaces, there are a few simple things that can make your node.js code easier to read. We've been using them in all the hapi modules for over 4 years now to great results. This list is by no means complete but it highlights the most useful elements that will give you immediate value in reducing bugs.
### Required modules
JavaScript makes it harder than most languages to know where variables are coming from. Variables assigned required modules are particularly important because they represent a singleton object shared with the entire application. There are also globals and module globals, along with function variables and arguments.
Traditionally, variables starting with an uppercase letter represent a class that must be instantiated using `new`. This was an important semantic in the early days of JavaScript but at this point, if you don't know `Date` requires `new Date()` you are probably very new. We have adopted Upper Camel Case variable names for all module global variables
@maheshbabu
maheshbabu / System Design.md
Created April 18, 2016 12:44 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@maheshbabu
maheshbabu / 01-intro.md
Created April 22, 2016 09:57 — forked from dwayne/01-intro.md
My notes from the book "ng-book: The Complete Book on AngularJS by Ari Lerner".

Introduction

Author: Ari Lerner.

AngularJS offers a single framework that can be used to build dynamic, client-centric applications. It provides:

  • Module support
  • DOM manipulation
  • Animations
  • Templating
@maheshbabu
maheshbabu / angular-resize.js
Created May 27, 2016 18:54 — forked from chrisjordanme/angular-resize.js
Angular Directive for Window Resize Event
angular.module('your-module-name', [])
.directive('onResize', ['$window', function ($window) {
return {
link: function (scope, el, attrs) {
var initialWidth = $window.innerWidth,
smallClass = attrs.resizeClass || 'yourDefault',
smallAttr = attrs.resizeAttr || 'yourDefault',
smallWidth = attrs.resizeWidth || 1024;
var setSmall = function () {
@maheshbabu
maheshbabu / loadMore.js
Created July 27, 2016 15:33 — forked from fraserxu/loadMore.js
Simple load more function for ng-repeat with limitTo filter
// set the default amount of items being displayed
$scope.limit= 5;
// loadMore function
$scope.loadMore = function() {
$scope.limit = $scope.items.length
}
@maheshbabu
maheshbabu / gist:1c01c7d4c2f4c5eff3a40e25c0ce8505
Created October 15, 2016 09:00 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@maheshbabu
maheshbabu / rm_mysql.md
Created October 26, 2016 06:45 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

brew remove mysql